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