|
|
@@ -8,7 +8,6 @@ use App\Repository\ArticleRepository;
|
|
|
use App\Service\TagService;
|
|
|
use Doctrine\ORM\EntityManagerInterface;
|
|
|
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
|
|
-use Symfony\Component\DependencyInjection\Attribute\Target;
|
|
|
use Symfony\Component\HttpFoundation\Request;
|
|
|
use Symfony\Component\HttpFoundation\Response;
|
|
|
use Symfony\Component\Routing\Attribute\Route;
|
|
|
@@ -31,16 +30,15 @@ final class ArticleController extends AbstractController
|
|
|
public function new(
|
|
|
Request $request,
|
|
|
EntityManagerInterface $entityManager,
|
|
|
- #[Target('blog_publishing')]
|
|
|
- WorkflowInterface $workflow,
|
|
|
+ WorkflowInterface $blogPublishingStateMachine,
|
|
|
TagService $tagService
|
|
|
): Response
|
|
|
{
|
|
|
$article = new Article($this->getUser());
|
|
|
$article->setContent('');
|
|
|
- $workflow->getMarking($article);
|
|
|
+ $blogPublishingStateMachine->getMarking($article);
|
|
|
|
|
|
- $transitions = $workflow->getEnabledTransitions($article);
|
|
|
+ $transitions = $blogPublishingStateMachine->getEnabledTransitions($article);
|
|
|
$transitionsChoice = [];
|
|
|
foreach($transitions as $transition) {
|
|
|
$transitionsChoice[$transition->getName()] = $transition->getName();
|
|
|
@@ -54,7 +52,7 @@ final class ArticleController extends AbstractController
|
|
|
if ($form->isSubmitted() && $form->isValid()) {
|
|
|
$publicationChoice = $form->get('publicationChoice')->getData();
|
|
|
if ($publicationChoice !== null) {
|
|
|
- $workflow->apply($article, $publicationChoice);
|
|
|
+ $blogPublishingStateMachine->apply($article, $publicationChoice);
|
|
|
}
|
|
|
|
|
|
$entityManager->persist($article);
|
|
|
@@ -86,12 +84,11 @@ final class ArticleController extends AbstractController
|
|
|
Request $request,
|
|
|
Article $article,
|
|
|
EntityManagerInterface $entityManager,
|
|
|
- #[Target('blog_publishing')]
|
|
|
- WorkflowInterface $workflow,
|
|
|
+ WorkflowInterface $blogPublishingStateMachine,
|
|
|
TagService $tagService
|
|
|
): Response
|
|
|
{
|
|
|
- $transitions = $workflow->getEnabledTransitions($article);
|
|
|
+ $transitions = $blogPublishingStateMachine->getEnabledTransitions($article);
|
|
|
$transitionsChoice = [];
|
|
|
foreach($transitions as $transition) {
|
|
|
$transitionsChoice[$transition->getName()] = $transition->getName();
|
|
|
@@ -106,7 +103,7 @@ final class ArticleController extends AbstractController
|
|
|
if ($form->isSubmitted() && $form->isValid()) {
|
|
|
$publicationChoice = $form->get('publicationChoice')->getData();
|
|
|
if ($publicationChoice !== null) {
|
|
|
- $workflow->apply($article, $publicationChoice);
|
|
|
+ $blogPublishingStateMachine->apply($article, $publicationChoice);
|
|
|
}
|
|
|
|
|
|
$entityManager->flush();
|