mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-28 02:23:51 +00:00
implementing workflow on tasks
This commit is contained in:
@@ -9,12 +9,30 @@ use Symfony\Component\Workflow\Registry;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\Routing\Annotation\Route;
|
||||
|
||||
|
||||
class TaskController extends Controller
|
||||
{
|
||||
/**
|
||||
* Apply a transition to a task
|
||||
*
|
||||
* @Route(
|
||||
* "/{_locale}/task/transition/{kind}/{taskId}/{transition}",
|
||||
* name="chill_task_task_transition"
|
||||
* )
|
||||
*
|
||||
* @param string $kind
|
||||
* @param int $taskId
|
||||
* @param string $transition
|
||||
* @param SingleTaskRepository $singleTaskRepository
|
||||
* @param Registry $registry
|
||||
* @param EntityManagerInterface $em
|
||||
* @param Request $request
|
||||
* @return Response
|
||||
*/
|
||||
public function applyTransitionAction(
|
||||
$type,
|
||||
$kind,
|
||||
$taskId,
|
||||
$transition,
|
||||
SingleTaskRepository $singleTaskRepository,
|
||||
@@ -22,7 +40,7 @@ class TaskController extends Controller
|
||||
EntityManagerInterface $em,
|
||||
Request $request
|
||||
) {
|
||||
switch ($type) {
|
||||
switch ($kind) {
|
||||
case 'single-task':
|
||||
$task = $singleTaskRepository
|
||||
->find($taskId)
|
||||
@@ -33,7 +51,7 @@ class TaskController extends Controller
|
||||
);
|
||||
break;
|
||||
default:
|
||||
return new Response("The type '$type' is not implemented",
|
||||
return new Response("The type '$kind' is not implemented",
|
||||
Response::HTTP_BAD_REQUEST);
|
||||
}
|
||||
|
||||
@@ -44,7 +62,7 @@ class TaskController extends Controller
|
||||
|
||||
// we simply check that the user can see the task. Other ACL checks
|
||||
// should be performed using `guard` events.
|
||||
$this->denyAccessUnlessGranted($task, TaskVoter::SHOW);
|
||||
$this->denyAccessUnlessGranted(TaskVoter::SHOW, $task);
|
||||
|
||||
$workflow = $registry->get($task);
|
||||
|
||||
|
Reference in New Issue
Block a user