implementing workflow on tasks

This commit is contained in:
2018-04-25 15:35:52 +02:00
parent 4fe9c4296e
commit c99583b665
13 changed files with 429 additions and 12 deletions

View File

@@ -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);