Skip to content

Commit be8f77a

Browse files
committed
Backport PR #127
1 parent 3bd5677 commit be8f77a

4 files changed

Lines changed: 44 additions & 11 deletions

File tree

Controller/TicketController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public function indexAction(Request $request)
3333
$ticketState = $request->get('state', $this->get('translator')->trans('STATUS_OPEN'));
3434
$ticketPriority = $request->get('priority', null);
3535

36-
$query = $ticketManager->getTicketList(
36+
$query = $ticketManager->getTicketListQuery(
3737
$userManager,
3838
$ticketManager->getTicketStatus($ticketState),
3939
$ticketManager->getTicketPriority($ticketPriority)

Manager/TicketManager.php

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -100,13 +100,7 @@ public function createMessage(TicketInterface $ticket = null)
100100
}
101101

102102
/**
103-
* Update or Create a Ticket in the database
104-
* Update or Create a TicketMessage in the database.
105-
*
106-
* @param TicketInterface $ticket
107-
* @param TicketMessageInterface $message
108-
*
109-
* @return TicketInterface
103+
* {@inheritdoc}
110104
*/
111105
public function updateTicket(TicketInterface $ticket, TicketMessageInterface $message = null)
112106
{
@@ -119,13 +113,14 @@ public function updateTicket(TicketInterface $ticket, TicketMessageInterface $me
119113
}
120114
$this->objectManager->flush();
121115

116+
// NEXT_MAJOR: Remove the `return` statement.
122117
return $ticket;
123118
}
124119

125120
/**
126121
* Delete a ticket from the database.
127122
*
128-
* @param TicketInterface $ticket*
123+
* @param TicketInterface $ticket
129124
*/
130125
public function deleteTicket(TicketInterface $ticket)
131126
{
@@ -180,16 +175,34 @@ public function findTicketsBy(array $criteria)
180175
}
181176

182177
/**
178+
* NEXT_MAJOR: Remove this method.
179+
*
180+
* @deprecated since hackzilla/ticket-bundle 3.3, use `getTicketListQuery()` instead.
181+
*
183182
* @param UserManagerInterface $userManager
184183
* @param int $ticketStatus
185184
* @param int $ticketPriority
186185
*
187186
* @return mixed
188187
*/
189188
public function getTicketList(UserManagerInterface $userManager, $ticketStatus, $ticketPriority = null)
189+
{
190+
@trigger_error(sprintf(
191+
'Method `%s()` is deprecated since hackzilla/ticket-bundle 3.3 and will be removed in version 4.0.'
192+
.' Use `%s::getTicketListQuery()` instead.',
193+
__METHOD__,
194+
__CLASS__
195+
), E_USER_DEPRECATED);
196+
197+
return $query->getTicketListQuery($userManager, $ticketStatus, $ticketPriority);
198+
}
199+
200+
/**
201+
* {@inheritdoc}
202+
*/
203+
public function getTicketListQuery(UserManagerInterface $userManager, $ticketStatus, $ticketPriority = null)
190204
{
191205
$query = $this->ticketRepository->createQueryBuilder('t')
192-
// ->select($this->ticketClass.' t')
193206
->orderBy('t.lastMessage', 'DESC');
194207

195208
switch ($ticketStatus) {

Manager/TicketManagerInterface.php

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,15 @@
22

33
namespace Hackzilla\Bundle\TicketBundle\Manager;
44

5+
use Doctrine\ORM\QueryBuilder;
56
use Doctrine\Common\Persistence\ObjectManager;
67
use Hackzilla\Bundle\TicketBundle\Model\TicketInterface;
78
use Hackzilla\Bundle\TicketBundle\Model\TicketMessageInterface;
89
use Symfony\Component\Translation\TranslatorInterface;
910

11+
/**
12+
* @method QueryBuilder getTicketListQuery(UserManagerInterface $userManager, $ticketStatus, $ticketPriority = null)
13+
*/
1014
interface TicketManagerInterface
1115
{
1216
public function setEntityManager(ObjectManager $om);
@@ -17,6 +21,9 @@ public function createTicket();
1721

1822
public function createMessage(TicketInterface $ticket = null);
1923

24+
/**
25+
* @return void
26+
*/
2027
public function updateTicket(TicketInterface $ticket, TicketMessageInterface $message = null);
2128

2229
public function deleteTicket(TicketInterface $ticket);
@@ -30,11 +37,15 @@ public function findTickets();
3037
public function findTicketsBy(array $criteria);
3138

3239
/**
40+
* NEXT_MAJOR: Remove this method.
41+
*
42+
* @deprecated since hackzilla/ticket-bundle 3.3, use `getTicketListQuery()` instead.
43+
*
3344
* @param UserManagerInterface $userManager
3445
* @param int $ticketStatus
3546
* @param int $ticketPriority
3647
*
37-
* @return mixed
48+
* @return QueryBuilder
3849
*/
3950
public function getTicketList(UserManagerInterface $userManager, $ticketStatus, $ticketPriority = null);
4051

UPGRADE-3.x.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
UPGRADE FROM 3.2 to 3.3
2+
=======================
3+
4+
## Hackzilla\Bundle\TicketBundle\Manager\TicketManagerInterface and Hackzilla\Bundle\TicketBundle\Manager\TicketManager
5+
6+
* Deprecated method `getTicketList()` in favor of `getTicketListQuery()`.
7+
8+
* Deprecated relying on the return value of `updateTicket()`, since its the same object
9+
provided at argument 1. This method will return void in version 4.0.

0 commit comments

Comments
 (0)