Skip to content

Commit 94bf989

Browse files
committed
Merge branch 'release/3.0'
2 parents 800cfe4 + c062ec6 commit 94bf989

72 files changed

Lines changed: 2412 additions & 1202 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.styleci.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,4 @@ enabled:
1010
disabled:
1111
- unalign_double_arrow
1212
- unalign_equals
13+
- simplified_null_return

Command/TicketManagerCommand.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
5555
->setMessage($input->getArgument('message'))
5656
->setStatus(TicketMessage::STATUS_OPEN)
5757
->setPriority($input->getOption('priority'))
58-
->setUser($userManager->findUserByUsername('system'))
59-
->setTicket($ticket);
58+
->setUser($userManager->findUserByUsername('system'));
6059

6160
$ticketManager->updateTicket($ticket, $message);
6261

Component/TicketFeatures.php

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
<?php
2+
3+
namespace Hackzilla\Bundle\TicketBundle\Component;
4+
5+
use Hackzilla\Bundle\TicketBundle\Model\TicketFeature\MessageAttachmentInterface;
6+
7+
class TicketFeatures
8+
{
9+
private $features;
10+
11+
/**
12+
* @param array $features
13+
* @param string $messageClass TicketMessage class
14+
*/
15+
public function __construct(array $features, $messageClass)
16+
{
17+
if (!empty($features['attachment']) && !is_a($messageClass, MessageAttachmentInterface::class, true)
18+
) {
19+
$features['attachment'] = false;
20+
}
21+
22+
$this->features = $features;
23+
}
24+
25+
/**
26+
* Check if feature exists or whether enabled.
27+
*
28+
* @param $feature
29+
*
30+
* @return bool|null
31+
*/
32+
public function hasFeature($feature)
33+
{
34+
if (!isset($this->features[$feature])) {
35+
return null;
36+
}
37+
38+
return $this->features[$feature];
39+
}
40+
}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
<?php
2+
3+
namespace Hackzilla\Bundle\TicketBundle\Controller;
4+
5+
use Hackzilla\Bundle\TicketBundle\Entity\TicketMessageWithAttachment;
6+
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
7+
8+
/**
9+
* Ticket Attachment controller.
10+
*
11+
* Download attachments
12+
*/
13+
class TicketAttachmentController extends Controller
14+
{
15+
/**
16+
* Download attachment on message.
17+
*
18+
* @param int $ticketMessageId
19+
*
20+
* @return \Symfony\Component\HttpFoundation\Response
21+
*/
22+
public function downloadAction($ticketMessageId)
23+
{
24+
$ticketManager = $this->get('hackzilla_ticket.ticket_manager');
25+
$ticketMessage = $ticketManager->getMessageById($ticketMessageId);
26+
27+
if (!$ticketMessage || !$ticketMessage instanceof TicketMessageWithAttachment) {
28+
throw $this->createNotFoundException($this->get('translator')->trans('ERROR_FIND_TICKET_ENTITY'));
29+
}
30+
31+
// check permissions
32+
$userManager = $this->get('hackzilla_ticket.user_manager');
33+
$userManager->hasPermission($userManager->getCurrentUser(), $ticketMessage->getTicket());
34+
35+
$downloadHandler = $this->get('vich_uploader.download_handler');
36+
37+
return $downloadHandler->downloadObject($ticketMessage, 'attachmentFile');
38+
}
39+
}

0 commit comments

Comments
 (0)