|
@@ -5,6 +5,7 @@ namespace App\Controller;
|
|
|
use App\Entity\Article;
|
|
|
use App\Form\ArticleType;
|
|
|
use App\Repository\ArticleRepository;
|
|
|
+use App\Service\TagService;
|
|
|
use Doctrine\ORM\EntityManagerInterface;
|
|
|
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
|
|
use Symfony\Component\DependencyInjection\Attribute\Target;
|
|
@@ -31,7 +32,8 @@ final class ArticleController extends AbstractController
|
|
|
Request $request,
|
|
|
EntityManagerInterface $entityManager,
|
|
|
#[Target('blog_publishing')]
|
|
|
- WorkflowInterface $workflow
|
|
|
+ WorkflowInterface $workflow,
|
|
|
+ TagService $tagService
|
|
|
): Response
|
|
|
{
|
|
|
$article = new Article($this->getUser());
|
|
@@ -58,6 +60,8 @@ final class ArticleController extends AbstractController
|
|
|
$entityManager->persist($article);
|
|
|
$entityManager->flush();
|
|
|
|
|
|
+ $tagService->clearOrphansTags();
|
|
|
+
|
|
|
return $this->redirectToRoute('app_article_show', ['id' => $article->getId()], Response::HTTP_SEE_OTHER);
|
|
|
}
|
|
|
|
|
@@ -83,7 +87,8 @@ final class ArticleController extends AbstractController
|
|
|
Article $article,
|
|
|
EntityManagerInterface $entityManager,
|
|
|
#[Target('blog_publishing')]
|
|
|
- WorkflowInterface $workflow
|
|
|
+ WorkflowInterface $workflow,
|
|
|
+ TagService $tagService
|
|
|
): Response
|
|
|
{
|
|
|
$transitions = $workflow->getEnabledTransitions($article);
|
|
@@ -103,8 +108,10 @@ final class ArticleController extends AbstractController
|
|
|
if ($publicationChoice !== null) {
|
|
|
$workflow->apply($article, $publicationChoice);
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
$entityManager->flush();
|
|
|
+
|
|
|
+ $tagService->clearOrphansTags();
|
|
|
|
|
|
return $this->redirectToRoute('app_article_show', ['id' => $article->getId()], Response::HTTP_SEE_OTHER);
|
|
|
}
|