vendor/kunstmaan/node-bundle/Controller/NodeAdminController.php line 702

Open in your IDE?
  1. <?php
  2. namespace Kunstmaan\NodeBundle\Controller;
  3. use Doctrine\Common\Collections\ArrayCollection;
  4. use Doctrine\ORM\EntityManager;
  5. use Doctrine\ORM\EntityManagerInterface;
  6. use Kunstmaan\AdminBundle\Entity\BaseUser;
  7. use Kunstmaan\AdminBundle\FlashMessages\FlashTypes;
  8. use Kunstmaan\AdminBundle\Helper\CloneHelper;
  9. use Kunstmaan\AdminBundle\Helper\DomainConfigurationInterface;
  10. use Kunstmaan\AdminBundle\Helper\FormWidgets\FormWidget;
  11. use Kunstmaan\AdminBundle\Helper\FormWidgets\Tabs\Tab;
  12. use Kunstmaan\AdminBundle\Helper\FormWidgets\Tabs\TabPane;
  13. use Kunstmaan\AdminBundle\Helper\Security\Acl\AclHelper;
  14. use Kunstmaan\AdminBundle\Helper\Security\Acl\Permission\PermissionMap;
  15. use Kunstmaan\AdminBundle\Service\AclManager;
  16. use Kunstmaan\AdminListBundle\AdminList\AdminList;
  17. use Kunstmaan\AdminListBundle\AdminList\AdminListFactory;
  18. use Kunstmaan\NodeBundle\AdminList\NodeAdminListConfigurator;
  19. use Kunstmaan\NodeBundle\Entity\HasNodeInterface;
  20. use Kunstmaan\NodeBundle\Entity\Node;
  21. use Kunstmaan\NodeBundle\Entity\NodeTranslation;
  22. use Kunstmaan\NodeBundle\Entity\NodeVersion;
  23. use Kunstmaan\NodeBundle\Entity\QueuedNodeTranslationAction;
  24. use Kunstmaan\NodeBundle\Event\AdaptFormEvent;
  25. use Kunstmaan\NodeBundle\Event\CopyPageTranslationNodeEvent;
  26. use Kunstmaan\NodeBundle\Event\Events;
  27. use Kunstmaan\NodeBundle\Event\NodeEvent;
  28. use Kunstmaan\NodeBundle\Event\RecopyPageTranslationNodeEvent;
  29. use Kunstmaan\NodeBundle\Event\RevertNodeAction;
  30. use Kunstmaan\NodeBundle\Form\NodeMenuTabAdminType;
  31. use Kunstmaan\NodeBundle\Form\NodeMenuTabTranslationAdminType;
  32. use Kunstmaan\NodeBundle\Helper\Menu\ActionsMenuBuilder;
  33. use Kunstmaan\NodeBundle\Helper\NodeAdmin\NodeAdminPublisher;
  34. use Kunstmaan\NodeBundle\Helper\NodeAdmin\NodeVersionLockHelper;
  35. use Kunstmaan\NodeBundle\Helper\PageCloningHelper;
  36. use Kunstmaan\NodeBundle\Helper\Services\ACLPermissionCreatorService;
  37. use Kunstmaan\NodeBundle\Repository\NodeVersionRepository;
  38. use Kunstmaan\UtilitiesBundle\Helper\ClassLookup;
  39. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  40. use Symfony\Component\Form\FormFactoryInterface;
  41. use Symfony\Component\HttpFoundation\JsonResponse;
  42. use Symfony\Component\HttpFoundation\RedirectResponse;
  43. use Symfony\Component\HttpFoundation\Request;
  44. use Symfony\Component\HttpFoundation\RequestStack;
  45. use Symfony\Component\HttpFoundation\Response;
  46. use Symfony\Component\Routing\Annotation\Route;
  47. use Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface;
  48. use Symfony\Component\Security\Core\Exception\AccessDeniedException;
  49. use Symfony\Contracts\EventDispatcher\EventDispatcherInterface;
  50. use Symfony\Contracts\Translation\TranslatorInterface;
  51. final class NodeAdminController extends AbstractController
  52. {
  53.     /**
  54.      * @var EntityManager
  55.      */
  56.     protected $em;
  57.     /**
  58.      * @var string
  59.      */
  60.     protected $locale;
  61.     /**
  62.      * @var AuthorizationCheckerInterface
  63.      */
  64.     protected $authorizationChecker;
  65.     /**
  66.      * @var BaseUser
  67.      */
  68.     protected $user;
  69.     /**
  70.      * @var AclHelper
  71.      */
  72.     protected $aclHelper;
  73.     /**
  74.      * @var AclManager
  75.      */
  76.     protected $aclManager;
  77.     /**
  78.      * @var NodeAdminPublisher
  79.      */
  80.     protected $nodePublisher;
  81.     /**
  82.      * @var TranslatorInterface
  83.      */
  84.     protected $translator;
  85.     /** @var PageCloningHelper */
  86.     private $pageCloningHelper;
  87.     /** @var DomainConfigurationInterface */
  88.     private $domainConfiguration;
  89.     public function __construct(DomainConfigurationInterface $domainConfiguration, EntityManagerInterface $em)
  90.     {
  91.         $this->domainConfiguration = $domainConfiguration;
  92.         $this->em = $em;
  93.     }
  94.     /**
  95.      * init
  96.      */
  97.     protected function init(Request $request)
  98.     {
  99.         $this->locale = $request->getLocale();
  100.         $this->authorizationChecker = $this->container->get('security.authorization_checker');
  101.         $this->user = $this->getUser();
  102.         $this->aclHelper = $this->container->get('kunstmaan_admin.acl.helper');
  103.         $this->aclManager = $this->container->get('kunstmaan_admin.acl.manager');
  104.         $this->nodePublisher = $this->container->get('kunstmaan_node.admin_node.publisher');
  105.         $this->translator = $this->container->get('translator');
  106.         $this->pageCloningHelper = $this->container->get(PageCloningHelper::class);
  107.     }
  108.     #[Route(path: '/', name: 'KunstmaanNodeBundle_nodes')]
  109.     public function indexAction(Request $request): Response
  110.     {
  111.         $this->init($request);
  112.         $nodeAdminListConfigurator = $this->getAdminListConfigurator();
  113.         $nodeAdminListConfigurator->setShowAddHomepage($this->getParameter('kunstmaan_node.show_add_homepage') && $this->isGranted('ROLE_SUPER_ADMIN'));
  114.         /** @var AdminList $adminlist */
  115.         $adminlist = $this->container->get('kunstmaan_adminlist.factory')->createList($nodeAdminListConfigurator);
  116.         $adminlist->bindRequest($request);
  117.         return $this->render('@KunstmaanNode/Admin/list.html.twig', [
  118.             'adminlist' => $adminlist,
  119.         ]);
  120.     }
  121.     #[Route(path: '/{nodeId}/items', name: 'KunstmaanNodeBundle_nodes_items')]
  122.     public function itemsAction(Request $request, int $nodeId): Response
  123.     {
  124.         $this->init($request);
  125.         $node = $this->em->getRepository(Node::class)->find($nodeId);
  126.         if (!$node) {
  127.             throw $this->createNotFoundException(sprintf('No node found for id "%s"', $nodeId));
  128.         }
  129.         $nodeAdminListConfigurator = $this->getAdminListConfigurator($node);
  130.         /** @var AdminList $adminlist */
  131.         $adminlist = $this->container->get('kunstmaan_adminlist.factory')->createList($nodeAdminListConfigurator);
  132.         $adminlist->bindRequest($request);
  133.         return $this->render('@KunstmaanNode/Admin/list.html.twig', [
  134.             'adminlist' => $adminlist,
  135.         ]);
  136.     }
  137.     public function getAdminListConfigurator(?Node $node = null): NodeAdminListConfigurator
  138.     {
  139.         $nodeAdminListConfigurator = new NodeAdminListConfigurator(
  140.             $this->em,
  141.             $this->aclHelper,
  142.             $this->locale,
  143.             PermissionMap::PERMISSION_VIEW,
  144.             $this->authorizationChecker,
  145.             $node
  146.         );
  147.         $nodeAdminListConfigurator->setDomainConfiguration($this->domainConfiguration);
  148.         return $nodeAdminListConfigurator;
  149.     }
  150.     /**
  151.      * @param int $id The node id
  152.      */
  153.     #[Route(path: '/{id}/copyfromotherlanguage', requirements: ['id' => '\d+'], name: 'KunstmaanNodeBundle_nodes_copyfromotherlanguage', methods: ['GET'])]
  154.     public function copyFromOtherLanguageAction(Request $request, $id): RedirectResponse
  155.     {
  156.         $this->init($request);
  157.         /* @var Node $node */
  158.         $node = $this->em->getRepository(Node::class)->find($id);
  159.         $this->denyAccessUnlessGranted(PermissionMap::PERMISSION_EDIT, $node);
  160.         $originalLanguage = $request->query->get('originallanguage');
  161.         $otherLanguageNodeTranslation = $node->getNodeTranslation($originalLanguage, true);
  162.         $otherLanguageNodeNodeVersion = $otherLanguageNodeTranslation->getPublicNodeVersion();
  163.         $otherLanguagePage = $otherLanguageNodeNodeVersion->getRef($this->em);
  164.         $myLanguagePage = $this->container->get('kunstmaan_admin.clone.helper')
  165.             ->deepCloneAndSave($otherLanguagePage);
  166.         /* @var NodeTranslation $nodeTranslation */
  167.         $nodeTranslation = $this->em->getRepository(NodeTranslation::class)
  168.             ->createNodeTranslationFor($myLanguagePage, $this->locale, $node, $this->user);
  169.         $nodeVersion = $nodeTranslation->getPublicNodeVersion();
  170.         $this->dispatch(
  171.             new CopyPageTranslationNodeEvent(
  172.                 $node,
  173.                 $nodeTranslation,
  174.                 $nodeVersion,
  175.                 $myLanguagePage,
  176.                 $otherLanguageNodeTranslation,
  177.                 $otherLanguageNodeNodeVersion,
  178.                 $otherLanguagePage,
  179.                 $originalLanguage
  180.             ),
  181.             Events::COPY_PAGE_TRANSLATION
  182.         );
  183.         return $this->redirectToRoute('KunstmaanNodeBundle_nodes_edit', ['id' => $id]);
  184.     }
  185.     /**
  186.      * @param int $id The node id
  187.      */
  188.     #[Route(path: '/{id}/recopyfromotherlanguage', requirements: ['id' => '\d+'], name: 'KunstmaanNodeBundle_nodes_recopyfromotherlanguage', methods: ['POST'])]
  189.     public function recopyFromOtherLanguageAction(Request $request, $id): RedirectResponse
  190.     {
  191.         if (!$this->isCsrfTokenValid('recopy-from-language', $request->request->get('token'))) {
  192.             return $this->redirectToRoute('KunstmaanNodeBundle_nodes_edit', ['id' => $id]);
  193.         }
  194.         $this->init($request);
  195.         /* @var Node $node */
  196.         $node = $this->em->getRepository(Node::class)->find($id);
  197.         $this->denyAccessUnlessGranted(PermissionMap::PERMISSION_EDIT, $node);
  198.         $otherLanguageNodeTranslation = $this->em->getRepository(NodeTranslation::class)->find($request->request->get('source'));
  199.         $otherLanguageNodeNodeVersion = $otherLanguageNodeTranslation->getPublicNodeVersion();
  200.         $otherLanguagePage = $otherLanguageNodeNodeVersion->getRef($this->em);
  201.         $myLanguagePage = $this->container->get('kunstmaan_admin.clone.helper')
  202.             ->deepCloneAndSave($otherLanguagePage);
  203.         /* @var NodeTranslation $nodeTranslation */
  204.         $nodeTranslation = $this->em->getRepository(NodeTranslation::class)
  205.             ->addDraftNodeVersionFor($myLanguagePage, $this->locale, $node, $this->user);
  206.         $nodeVersion = $nodeTranslation->getPublicNodeVersion();
  207.         $this->dispatch(
  208.             new RecopyPageTranslationNodeEvent(
  209.                 $node,
  210.                 $nodeTranslation,
  211.                 $nodeVersion,
  212.                 $myLanguagePage,
  213.                 $otherLanguageNodeTranslation,
  214.                 $otherLanguageNodeNodeVersion,
  215.                 $otherLanguagePage,
  216.                 $otherLanguageNodeTranslation->getLang()
  217.             ),
  218.             Events::RECOPY_PAGE_TRANSLATION
  219.         );
  220.         return $this->redirectToRoute('KunstmaanNodeBundle_nodes_edit', ['id' => $id, 'subaction' => NodeVersion::DRAFT_VERSION]);
  221.     }
  222.     /**
  223.      * @param int $id
  224.      */
  225.     #[Route(path: '/{id}/createemptypage', requirements: ['id' => '\d+'], name: 'KunstmaanNodeBundle_nodes_createemptypage', methods: ['GET'])]
  226.     public function createEmptyPageAction(Request $request, $id): RedirectResponse
  227.     {
  228.         $this->init($request);
  229.         /* @var Node $node */
  230.         $node = $this->em->getRepository(Node::class)->find($id);
  231.         $this->denyAccessUnlessGranted(PermissionMap::PERMISSION_EDIT, $node);
  232.         $entityName = $node->getRefEntityName();
  233.         /* @var HasNodeInterface $myLanguagePage */
  234.         $myLanguagePage = new $entityName();
  235.         $myLanguagePage->setTitle('New page');
  236.         $this->em->persist($myLanguagePage);
  237.         $this->em->flush();
  238.         /* @var NodeTranslation $nodeTranslation */
  239.         $nodeTranslation = $this->em->getRepository(NodeTranslation::class)
  240.             ->createNodeTranslationFor($myLanguagePage, $this->locale, $node, $this->user);
  241.         $nodeVersion = $nodeTranslation->getPublicNodeVersion();
  242.         $this->dispatch(
  243.             new NodeEvent($node, $nodeTranslation, $nodeVersion, $myLanguagePage),
  244.             Events::ADD_EMPTY_PAGE_TRANSLATION
  245.         );
  246.         return $this->redirectToRoute('KunstmaanNodeBundle_nodes_edit', ['id' => $id]);
  247.     }
  248.     /**
  249.      * @param int $id
  250.      */
  251.     #[Route(path: '/{id}/publish', requirements: ['id' => '\d+'], name: 'KunstmaanNodeBundle_nodes_publish', methods: ['GET', 'POST'])]
  252.     public function publishAction(Request $request, $id): RedirectResponse
  253.     {
  254.         $this->init($request);
  255.         /* @var Node $node */
  256.         $node = $this->em->getRepository(Node::class)->find($id);
  257.         $nodeTranslation = $node->getNodeTranslation($this->locale, true);
  258.         $request = $this->container->get('request_stack')->getCurrentRequest();
  259.         $this->nodePublisher->handlePublish($request, $nodeTranslation);
  260.         return $this->redirectToRoute('KunstmaanNodeBundle_nodes_edit', ['id' => $node->getId()]);
  261.     }
  262.     /**
  263.      * @param int $id
  264.      */
  265.     #[Route(path: '/{id}/unpublish', requirements: ['id' => '\d+'], name: 'KunstmaanNodeBundle_nodes_unpublish', methods: ['GET', 'POST'])]
  266.     public function unPublishAction(Request $request, $id): RedirectResponse
  267.     {
  268.         $this->init($request);
  269.         /* @var Node $node */
  270.         $node = $this->em->getRepository(Node::class)->find($id);
  271.         $nodeTranslation = $node->getNodeTranslation($this->locale, true);
  272.         $request = $this->container->get('request_stack')->getCurrentRequest();
  273.         $this->nodePublisher->handleUnpublish($request, $nodeTranslation);
  274.         return $this->redirectToRoute('KunstmaanNodeBundle_nodes_edit', ['id' => $node->getId()]);
  275.     }
  276.     /**
  277.      * @param int $id
  278.      */
  279.     #[Route(path: '/{id}/unschedulepublish', requirements: ['id' => '\d+'], name: 'KunstmaanNodeBundle_nodes_unschedule_publish', methods: ['GET', 'POST'])]
  280.     public function unSchedulePublishAction(Request $request, $id): RedirectResponse
  281.     {
  282.         $this->init($request);
  283.         /* @var Node $node */
  284.         $node = $this->em->getRepository(Node::class)->find($id);
  285.         $nodeTranslation = $node->getNodeTranslation($this->locale, true);
  286.         $this->nodePublisher->unSchedulePublish($nodeTranslation);
  287.         $this->addFlash(
  288.             FlashTypes::SUCCESS,
  289.             $this->container->get('translator')->trans('kuma_node.admin.unschedule.flash.success')
  290.         );
  291.         return $this->redirectToRoute('KunstmaanNodeBundle_nodes_edit', ['id' => $id]);
  292.     }
  293.     /**
  294.      * @param int $id
  295.      */
  296.     #[Route(path: '/{id}/delete', requirements: ['id' => '\d+'], name: 'KunstmaanNodeBundle_nodes_delete', methods: ['POST'])]
  297.     public function deleteAction(Request $request, $id): RedirectResponse
  298.     {
  299.         $this->init($request);
  300.         /* @var Node $node */
  301.         $node = $this->em->getRepository(Node::class)->find($id);
  302.         $this->denyAccessUnlessGranted(PermissionMap::PERMISSION_DELETE, $node);
  303.         $nodeTranslation = $node->getNodeTranslation($this->locale, true);
  304.         $nodeVersion = $nodeTranslation->getPublicNodeVersion();
  305.         $page = $nodeVersion->getRef($this->em);
  306.         $this->dispatch(
  307.             new NodeEvent($node, $nodeTranslation, $nodeVersion, $page),
  308.             Events::PRE_DELETE
  309.         );
  310.         $node->setDeleted(true);
  311.         $this->em->persist($node);
  312.         $children = $node->getChildren();
  313.         $this->deleteNodeChildren($this->em, $this->user, $this->locale, $children);
  314.         $this->em->flush();
  315.         $event = new NodeEvent($node, $nodeTranslation, $nodeVersion, $page);
  316.         $this->dispatch($event, Events::POST_DELETE);
  317.         if (null === $response = $event->getResponse()) {
  318.             $nodeParent = $node->getParent();
  319.             // Check if we have a parent. Otherwise redirect to pages overview.
  320.             if ($nodeParent) {
  321.                 $url = $this->generateUrl('KunstmaanNodeBundle_nodes_edit', ['id' => $nodeParent->getId()]);
  322.             } else {
  323.                 $url = $this->generateUrl('KunstmaanNodeBundle_nodes');
  324.             }
  325.             $response = new RedirectResponse($url);
  326.         }
  327.         $this->addFlash(
  328.             FlashTypes::SUCCESS,
  329.             $this->container->get('translator')->trans('kuma_node.admin.delete.flash.success')
  330.         );
  331.         return $response;
  332.     }
  333.     /**
  334.      * @param int $id
  335.      */
  336.     #[Route(path: '/{id}/duplicate', requirements: ['id' => '\d+'], name: 'KunstmaanNodeBundle_nodes_duplicate', methods: ['POST'])]
  337.     public function duplicateAction(Request $request, $id): RedirectResponse
  338.     {
  339.         if (!$this->isCsrfTokenValid('node-duplicate', $request->request->get('token'))) {
  340.             return $this->redirectToRoute($this->generateUrl('KunstmaanNodeBundle_nodes_edit', ['id' => $id]));
  341.         }
  342.         $this->init($request);
  343.         /* @var Node $parentNode */
  344.         $originalNode = $this->em->getRepository(Node::class)
  345.             ->find($id);
  346.         // Check with Acl
  347.         $this->denyAccessUnlessGranted(PermissionMap::PERMISSION_EDIT, $originalNode);
  348.         $request = $this->container->get('request_stack')->getCurrentRequest();
  349.         $originalNodeTranslations = $originalNode->getNodeTranslation($this->locale, true);
  350.         $originalRef = $originalNodeTranslations->getPublicNodeVersion()->getRef($this->em);
  351.         $newPage = $this->container->get('kunstmaan_admin.clone.helper')
  352.             ->deepCloneAndSave($originalRef);
  353.         // set the title
  354.         $title = $request->request->get('title');
  355.         if (\is_string($title) && !empty($title)) {
  356.             $newPage->setTitle($title);
  357.         } else {
  358.             $newPage->setTitle('New page');
  359.         }
  360.         // set the parent
  361.         $parentNodeTranslation = $originalNode->getParent()->getNodeTranslation($this->locale, true);
  362.         $parent = $parentNodeTranslation->getPublicNodeVersion()->getRef($this->em);
  363.         $newPage->setParent($parent);
  364.         $this->em->persist($newPage);
  365.         $this->em->flush();
  366.         /* @var Node $nodeNewPage */
  367.         $nodeNewPage = $this->em->getRepository(Node::class)->createNodeFor(
  368.             $newPage,
  369.             $this->locale,
  370.             $this->user
  371.         );
  372.         $nodeTranslation = $nodeNewPage->getNodeTranslation($this->locale, true);
  373.         if ($newPage->isStructureNode()) {
  374.             $nodeTranslation->setSlug('');
  375.             $this->em->persist($nodeTranslation);
  376.         }
  377.         $this->em->flush();
  378.         $this->aclManager->updateNodeAcl($originalNode, $nodeNewPage);
  379.         $this->addFlash(
  380.             FlashTypes::SUCCESS,
  381.             $this->container->get('translator')->trans('kuma_node.admin.duplicate.flash.success')
  382.         );
  383.         return $this->redirectToRoute('KunstmaanNodeBundle_nodes_edit', ['id' => $nodeNewPage->getId()]);
  384.     }
  385.     #[Route(path: '/{id}/duplicate-with-children', requirements: ['id' => '\d+'], name: 'KunstmaanNodeBundle_nodes_duplicate_with_children', methods: ['POST'])]
  386.     public function duplicateWithChildrenAction(Request $request, $id)
  387.     {
  388.         if (!$this->isCsrfTokenValid('node-duplicate-with-children', $request->request->get('token'))) {
  389.             return $this->redirectToRoute($this->generateUrl('KunstmaanNodeBundle_nodes_edit', ['id' => $id]));
  390.         }
  391.         if (!$this->getParameter('kunstmaan_node.show_duplicate_with_children')) {
  392.             return $this->redirectToRoute('KunstmaanNodeBundle_nodes_edit', ['id' => $id]);
  393.         }
  394.         $this->init($request);
  395.         $title = $request->request->get('title');
  396.         $nodeNewPage = $this->pageCloningHelper->duplicateWithChildren($id, $this->locale, $this->user, $title);
  397.         $this->addFlash(FlashTypes::SUCCESS, $this->container->get('translator')->trans('kuma_node.admin.duplicate.flash.success'));
  398.         return $this->redirectToRoute('KunstmaanNodeBundle_nodes_edit', ['id' => $nodeNewPage->getId()]);
  399.     }
  400.     /**
  401.      * @param int $id The node id
  402.      */
  403.     #[Route(path: '/{id}/revert', requirements: ['id' => '\d+'], defaults: ['subaction' => 'public'], name: 'KunstmaanNodeBundle_nodes_revert', methods: ['GET'])]
  404.     public function revertAction(Request $request, $id): RedirectResponse
  405.     {
  406.         $this->init($request);
  407.         /* @var Node $node */
  408.         $node = $this->em->getRepository(Node::class)->find($id);
  409.         $this->denyAccessUnlessGranted(PermissionMap::PERMISSION_EDIT, $node);
  410.         $version = $request->query->get('version');
  411.         if (empty($version) || !is_numeric($version)) {
  412.             throw new \InvalidArgumentException('No version was specified');
  413.         }
  414.         /* @var NodeVersionRepository $nodeVersionRepo */
  415.         $nodeVersionRepo = $this->em->getRepository(NodeVersion::class);
  416.         /* @var NodeVersion $nodeVersion */
  417.         $nodeVersion = $nodeVersionRepo->find($version);
  418.         if (\is_null($nodeVersion)) {
  419.             throw new \InvalidArgumentException('Version does not exist');
  420.         }
  421.         /* @var NodeTranslation $nodeTranslation */
  422.         $nodeTranslation = $node->getNodeTranslation($this->locale, true);
  423.         $page = $nodeVersion->getRef($this->em);
  424.         /* @var HasNodeInterface $clonedPage */
  425.         $clonedPage = $this->container->get('kunstmaan_admin.clone.helper')
  426.             ->deepCloneAndSave($page);
  427.         $newNodeVersion = $nodeVersionRepo->createNodeVersionFor(
  428.             $clonedPage,
  429.             $nodeTranslation,
  430.             $this->user,
  431.             $nodeVersion,
  432.             'draft'
  433.         );
  434.         $nodeTranslation->setTitle($clonedPage->getTitle());
  435.         $this->em->persist($nodeTranslation);
  436.         $this->em->flush();
  437.         $this->dispatch(
  438.             new RevertNodeAction(
  439.                 $node,
  440.                 $nodeTranslation,
  441.                 $newNodeVersion,
  442.                 $clonedPage,
  443.                 $nodeVersion,
  444.                 $page
  445.             ),
  446.             Events::REVERT
  447.         );
  448.         $this->addFlash(
  449.             FlashTypes::SUCCESS,
  450.             $this->container->get('translator')->trans('kuma_node.admin.revert.flash.success')
  451.         );
  452.         return $this->redirectToRoute('KunstmaanNodeBundle_nodes_edit', [
  453.             'id' => $id,
  454.             'subaction' => 'draft',
  455.         ]);
  456.     }
  457.     /**
  458.      * @param int $id
  459.      */
  460.     #[Route(path: '/{id}/add', requirements: ['id' => '\d+'], name: 'KunstmaanNodeBundle_nodes_add', methods: ['POST'])]
  461.     public function addAction(Request $request, $id): RedirectResponse
  462.     {
  463.         $this->init($request);
  464.         /* @var Node $parentNode */
  465.         $parentNode = $this->em->getRepository(Node::class)->find($id);
  466.         // Check with Acl
  467.         $this->denyAccessUnlessGranted(PermissionMap::PERMISSION_EDIT, $parentNode);
  468.         $parentNodeTranslation = $parentNode->getNodeTranslation($this->locale, true);
  469.         $parentNodeVersion = $parentNodeTranslation->getPublicNodeVersion();
  470.         $parentPage = $parentNodeVersion->getRef($this->em);
  471.         $type = $this->validatePageType($request);
  472.         $newPage = $this->createNewPage($request, $type);
  473.         $newPage->setParent($parentPage);
  474.         /* @var Node $nodeNewPage */
  475.         $nodeNewPage = $this->em->getRepository(Node::class)
  476.             ->createNodeFor($newPage, $this->locale, $this->user);
  477.         $nodeTranslation = $nodeNewPage->getNodeTranslation(
  478.             $this->locale,
  479.             true
  480.         );
  481.         $weight = $this->em->getRepository(NodeTranslation::class)
  482.                 ->getMaxChildrenWeight($parentNode, $this->locale) + 1;
  483.         $nodeTranslation->setWeight($weight);
  484.         if ($newPage->isStructureNode()) {
  485.             $nodeTranslation->setSlug('');
  486.         }
  487.         $this->em->persist($nodeTranslation);
  488.         $this->em->flush();
  489.         $this->aclManager->updateNodeAcl($parentNode, $nodeNewPage);
  490.         $nodeVersion = $nodeTranslation->getPublicNodeVersion();
  491.         $this->dispatch(
  492.             new NodeEvent(
  493.                 $nodeNewPage, $nodeTranslation, $nodeVersion, $newPage
  494.             ),
  495.             Events::ADD_NODE
  496.         );
  497.         return $this->redirectToRoute('KunstmaanNodeBundle_nodes_edit', ['id' => $nodeNewPage->getId()]);
  498.     }
  499.     #[Route(path: '/add-homepage', name: 'KunstmaanNodeBundle_nodes_add_homepage', methods: ['POST'])]
  500.     public function addHomepageAction(Request $request): RedirectResponse
  501.     {
  502.         $this->init($request);
  503.         // Check with Acl
  504.         $this->denyAccessUnlessGranted('ROLE_SUPER_ADMIN');
  505.         $type = $this->validatePageType($request);
  506.         $newPage = $this->createNewPage($request, $type);
  507.         /* @var Node $nodeNewPage */
  508.         $nodeNewPage = $this->em->getRepository(Node::class)
  509.             ->createNodeFor($newPage, $this->locale, $this->user);
  510.         $nodeTranslation = $nodeNewPage->getNodeTranslation(
  511.             $this->locale,
  512.             true
  513.         );
  514.         $this->em->flush();
  515.         // Set default permissions
  516.         $this->container->get('kunstmaan_node.acl_permission_creator_service')
  517.             ->createPermission($nodeNewPage);
  518.         $nodeVersion = $nodeTranslation->getPublicNodeVersion();
  519.         $this->dispatch(
  520.             new NodeEvent(
  521.                 $nodeNewPage, $nodeTranslation, $nodeVersion, $newPage
  522.             ),
  523.             Events::ADD_NODE
  524.         );
  525.         return $this->redirectToRoute('KunstmaanNodeBundle_nodes_edit', ['id' => $nodeNewPage->getId()]);
  526.     }
  527.     #[Route(path: '/reorder', name: 'KunstmaanNodeBundle_nodes_reorder', methods: ['POST'])]
  528.     public function reorderAction(Request $request): Response
  529.     {
  530.         $this->init($request);
  531.         $nodes = [];
  532.         $nodeIds = $request->request->all('nodes');
  533.         $changeParents = $request->request->all('parent');
  534.         foreach ($nodeIds as $id) {
  535.             /* @var Node $node */
  536.             $node = $this->em->getRepository(Node::class)->find($id);
  537.             $this->denyAccessUnlessGranted(PermissionMap::PERMISSION_EDIT, $node);
  538.             $nodes[] = $node;
  539.         }
  540.         $weight = 1;
  541.         foreach ($nodes as $node) {
  542.             $newParentId = isset($changeParents[$node->getId()]) ? $changeParents[$node->getId()] : null;
  543.             if ($newParentId) {
  544.                 $parent = $this->em->getRepository(Node::class)->find($newParentId);
  545.                 $this->denyAccessUnlessGranted(PermissionMap::PERMISSION_EDIT, $parent);
  546.                 $node->setParent($parent);
  547.                 $this->em->persist($node);
  548.                 $this->em->flush();
  549.             }
  550.             /* @var NodeTranslation $nodeTranslation */
  551.             $nodeTranslation = $node->getNodeTranslation($this->locale, true);
  552.             if ($nodeTranslation) {
  553.                 $nodeVersion = $nodeTranslation->getPublicNodeVersion();
  554.                 $page = $nodeVersion->getRef($this->em);
  555.                 $this->dispatch(
  556.                     new NodeEvent($node, $nodeTranslation, $nodeVersion, $page),
  557.                     Events::PRE_PERSIST
  558.                 );
  559.                 $nodeTranslation->setWeight($weight);
  560.                 $this->em->persist($nodeTranslation);
  561.                 $this->em->flush();
  562.                 $this->dispatch(
  563.                     new NodeEvent($node, $nodeTranslation, $nodeVersion, $page),
  564.                     Events::POST_PERSIST
  565.                 );
  566.                 ++$weight;
  567.             }
  568.         }
  569.         return new JsonResponse([
  570.             'Success' => 'The node-translations for [' . $this->locale . '] have got new weight values',
  571.         ]);
  572.     }
  573.     /**
  574.      * @param int    $id        The node id
  575.      * @param string $subaction The subaction (draft|public)
  576.      */
  577.     #[Route(path: '/{id}/{subaction}', requirements: ['id' => '\d+'], defaults: ['subaction' => 'public'], name: 'KunstmaanNodeBundle_nodes_edit', methods: ['GET', 'POST'])]
  578.     public function editAction(Request $request, $id, $subaction): Response
  579.     {
  580.         $this->init($request);
  581.         /* @var Node $node */
  582.         $node = $this->em->getRepository(Node::class)->find($id);
  583.         if (!$node) {
  584.             throw $this->createNotFoundException(sprintf('No node found for id "%s"', $id));
  585.         }
  586.         $this->denyAccessUnlessGranted(PermissionMap::PERMISSION_EDIT, $node);
  587.         $tabPane = new TabPane(
  588.             'todo',
  589.             $request,
  590.             $this->container->get('form.factory')
  591.         );
  592.         $nodeTranslation = $node->getNodeTranslation($this->locale, true);
  593.         if (!$nodeTranslation) {
  594.             return $this->renderNodeNotTranslatedPage($node);
  595.         }
  596.         $nodeVersion = $nodeTranslation->getPublicNodeVersion();
  597.         $draftNodeVersion = $nodeTranslation->getDraftNodeVersion();
  598.         $nodeVersionIsLocked = false;
  599.         /* @var HasNodeInterface $page */
  600.         $page = null;
  601.         $draft = ($subaction == 'draft');
  602.         $saveAsDraft = $request->request->get('saveasdraft');
  603.         if ((!$draft && !empty($saveAsDraft)) || ($draft && \is_null($draftNodeVersion))) {
  604.             // Create a new draft version
  605.             $draft = true;
  606.             $subaction = 'draft';
  607.             $page = $nodeVersion->getRef($this->em);
  608.             $nodeVersion = $this->createDraftVersion(
  609.                 $page,
  610.                 $nodeTranslation,
  611.                 $nodeVersion
  612.             );
  613.             $draftNodeVersion = $nodeVersion;
  614.         } elseif ($draft) {
  615.             $nodeVersion = $draftNodeVersion;
  616.             $page = $nodeVersion->getRef($this->em);
  617.         } else {
  618.             if ($request->getMethod() == 'POST') {
  619.                 $nodeVersionIsLocked = $this->isNodeVersionLocked($nodeTranslation, true);
  620.                 // Check the version timeout and make a new nodeversion if the timeout is passed
  621.                 $thresholdDate = date(
  622.                     'Y-m-d H:i:s',
  623.                     time() - $this->getParameter(
  624.                         'kunstmaan_node.version_timeout'
  625.                     )
  626.                 );
  627.                 $updatedDate = date(
  628.                     'Y-m-d H:i:s',
  629.                     strtotime($nodeVersion->getUpdated()->format('Y-m-d H:i:s'))
  630.                 );
  631.                 if ($thresholdDate >= $updatedDate || $nodeVersionIsLocked) {
  632.                     $page = $nodeVersion->getRef($this->em);
  633.                     if ($nodeVersion === $nodeTranslation->getPublicNodeVersion()) {
  634.                         $this->nodePublisher
  635.                             ->createPublicVersion(
  636.                                 $page,
  637.                                 $nodeTranslation,
  638.                                 $nodeVersion,
  639.                                 $this->user
  640.                             );
  641.                     } else {
  642.                         $this->createDraftVersion(
  643.                             $page,
  644.                             $nodeTranslation,
  645.                             $nodeVersion
  646.                         );
  647.                     }
  648.                 }
  649.             }
  650.             $page = $nodeVersion->getRef($this->em);
  651.         }
  652.         $isStructureNode = $page->isStructureNode();
  653.         $menubuilder = $this->container->get('kunstmaan_node.actions_menu_builder');
  654.         $menubuilder->setActiveNodeVersion($nodeVersion);
  655.         $menubuilder->setEditableNode(!$isStructureNode);
  656.         // Building the form
  657.         $propertiesWidget = new FormWidget();
  658.         $propertiesWidget->addType('main', $page->getDefaultAdminType(), $page);
  659.         $propertiesWidget->addType('node', $node->getDefaultAdminType(), $node);
  660.         $tabPane->addTab(new Tab('kuma_node.tab.properties.title', $propertiesWidget));
  661.         // Menu tab
  662.         $menuWidget = new FormWidget();
  663.         $menuWidget->addType(
  664.             'menunodetranslation',
  665.             NodeMenuTabTranslationAdminType::class,
  666.             $nodeTranslation,
  667.             ['slugable' => !$isStructureNode]
  668.         );
  669.         $menuWidget->addType('menunode', NodeMenuTabAdminType::class, $node, ['available_in_nav' => !$isStructureNode]);
  670.         $tabPane->addTab(new Tab('kuma_node.tab.menu.title', $menuWidget));
  671.         $this->dispatch(
  672.             new AdaptFormEvent(
  673.                 $request,
  674.                 $tabPane,
  675.                 $page,
  676.                 $node,
  677.                 $nodeTranslation,
  678.                 $nodeVersion
  679.             ),
  680.             Events::ADAPT_FORM
  681.         );
  682.         $tabPane->buildForm();
  683.         if ($request->getMethod() == 'POST') {
  684.             $tabPane->bindRequest($request);
  685.             // Don't redirect to listing when coming from ajax request, needed for url chooser.
  686.             if ($tabPane->isValid() && !$request->isXmlHttpRequest()) {
  687.                 $this->dispatch(
  688.                     new NodeEvent($node, $nodeTranslation, $nodeVersion, $page),
  689.                     Events::PRE_PERSIST
  690.                 );
  691.                 $nodeTranslation->setTitle($page->getTitle());
  692.                 if ($isStructureNode) {
  693.                     $nodeTranslation->setSlug('');
  694.                 }
  695.                 $nodeVersion->setUpdated(new \DateTime());
  696.                 if ($nodeVersion->getType() == 'public') {
  697.                     $nodeTranslation->setUpdated($nodeVersion->getUpdated());
  698.                 }
  699.                 $this->em->persist($nodeTranslation);
  700.                 $this->em->persist($nodeVersion);
  701.                 $tabPane->persist($this->em);
  702.                 $this->em->flush();
  703.                 $this->dispatch(
  704.                     new NodeEvent($node, $nodeTranslation, $nodeVersion, $page),
  705.                     Events::POST_PERSIST
  706.                 );
  707.                 if ($nodeVersionIsLocked) {
  708.                     $this->addFlash(
  709.                         FlashTypes::SUCCESS,
  710.                         $this->container->get('translator')->trans('kuma_node.admin.edit.flash.locked_success')
  711.                     );
  712.                 } elseif ($request->request->has('publishing') || $request->request->has('publish_later')) {
  713.                     $this->nodePublisher->handlePublish($request, $nodeTranslation);
  714.                 } elseif ($request->request->has('unpublishing') || $request->request->has('unpublish_later')) {
  715.                     $this->nodePublisher->handleUnpublish($request, $nodeTranslation);
  716.                 } else {
  717.                     $this->addFlash(
  718.                         FlashTypes::SUCCESS,
  719.                         $this->container->get('translator')->trans('kuma_node.admin.edit.flash.success')
  720.                     );
  721.                 }
  722.                 $params = [
  723.                     'id' => $node->getId(),
  724.                     'subaction' => $subaction,
  725.                     'currenttab' => $tabPane->getActiveTab(),
  726.                 ];
  727.                 $params = array_merge(
  728.                     $params,
  729.                     $tabPane->getExtraParams($request)
  730.                 );
  731.                 if ($subaction === 'draft' && ($request->request->has('publishing') || $request->request->has('publish_later'))) {
  732.                     unset($params['subaction']);
  733.                 }
  734.                 return $this->redirectToRoute('KunstmaanNodeBundle_nodes_edit', $params);
  735.             }
  736.         }
  737.         $nodeVersions = $this->em->getRepository(NodeVersion::class)->findBy(
  738.             ['nodeTranslation' => $nodeTranslation],
  739.             ['updated' => 'DESC']
  740.         );
  741.         $queuedNodeTranslationAction = $this->em->getRepository(QueuedNodeTranslationAction::class)->findOneBy(['nodeTranslation' => $nodeTranslation]);
  742.         return $this->render('@KunstmaanNode/NodeAdmin/edit.html.twig', [
  743.             'page' => $page,
  744.             'entityname' => ClassLookup::getClass($page),
  745.             'nodeVersions' => $nodeVersions,
  746.             'node' => $node,
  747.             'nodeTranslation' => $nodeTranslation,
  748.             'draft' => $draft,
  749.             'draftNodeVersion' => $draftNodeVersion,
  750.             'showDuplicateWithChildren' => $this->getParameter('kunstmaan_node.show_duplicate_with_children'),
  751.             'nodeVersion' => $nodeVersion,
  752.             'subaction' => $subaction,
  753.             'tabPane' => $tabPane,
  754.             'editmode' => true,
  755.             'childCount' => $this->em->getRepository(Node::class)->getChildCount($node),
  756.             'queuedNodeTranslationAction' => $queuedNodeTranslationAction,
  757.             'nodeVersionLockCheck' => $this->getParameter('kunstmaan_node.lock_enabled'),
  758.             'nodeVersionLockInterval' => $this->getParameter('kunstmaan_node.lock_check_interval'),
  759.         ]);
  760.     }
  761.     #[Route(path: 'checkNodeVersionLock/{id}/{public}', requirements: ['id' => '\d+', 'public' => '(0|1)'], name: 'KunstmaanNodeBundle_nodes_versionlock_check')]
  762.     public function checkNodeVersionLockAction(Request $request, $id, $public): JsonResponse
  763.     {
  764.         $nodeVersionIsLocked = false;
  765.         $message = '';
  766.         $this->init($request);
  767.         /* @var Node $node */
  768.         $node = $this->em->getRepository(Node::class)->find($id);
  769.         try {
  770.             $this->checkPermission($node, PermissionMap::PERMISSION_EDIT);
  771.             /** @var NodeVersionLockHelper $nodeVersionLockHelper */
  772.             $nodeVersionLockHelper = $this->container->get('kunstmaan_node.admin_node.node_version_lock_helper');
  773.             $nodeTranslation = $node->getNodeTranslation($this->locale, true);
  774.             if ($nodeTranslation) {
  775.                 $nodeVersionIsLocked = $nodeVersionLockHelper->isNodeVersionLocked($this->getUser(), $nodeTranslation, $public);
  776.                 if ($nodeVersionIsLocked) {
  777.                     $users = $nodeVersionLockHelper->getUsersWithNodeVersionLock($nodeTranslation, $public, $this->getUser());
  778.                     $message = $this->container->get('translator')->trans('kuma_node.admin.edit.flash.locked', ['%users%' => implode(', ', $users)]);
  779.                 }
  780.             }
  781.         } catch (AccessDeniedException $ade) {
  782.         }
  783.         return new JsonResponse(['lock' => $nodeVersionIsLocked, 'message' => $message]);
  784.     }
  785.     /**
  786.      * @param bool $isPublic
  787.      */
  788.     private function isNodeVersionLocked(NodeTranslation $nodeTranslation, $isPublic): bool
  789.     {
  790.         if ($this->getParameter('kunstmaan_node.lock_enabled')) {
  791.             /** @var NodeVersionLockHelper $nodeVersionLockHelper */
  792.             $nodeVersionLockHelper = $this->container->get('kunstmaan_node.admin_node.node_version_lock_helper');
  793.             $nodeVersionIsLocked = $nodeVersionLockHelper->isNodeVersionLocked($this->getUser(), $nodeTranslation, $isPublic);
  794.             return $nodeVersionIsLocked;
  795.         }
  796.         return false;
  797.     }
  798.     /**
  799.      * @param HasNodeInterface $page            The page
  800.      * @param NodeTranslation  $nodeTranslation The node translation
  801.      * @param NodeVersion      $nodeVersion     The node version
  802.      *
  803.      * @return NodeVersion
  804.      */
  805.     private function createDraftVersion(
  806.         HasNodeInterface $page,
  807.         NodeTranslation $nodeTranslation,
  808.         NodeVersion $nodeVersion,
  809.     ) {
  810.         $publicPage = $this->container->get('kunstmaan_admin.clone.helper')
  811.             ->deepCloneAndSave($page);
  812.         /* @var NodeVersion $publicNodeVersion */
  813.         $publicNodeVersion = $this->em->getRepository(
  814.             NodeVersion::class
  815.         )->createNodeVersionFor(
  816.             $publicPage,
  817.             $nodeTranslation,
  818.             $this->user,
  819.             $nodeVersion->getOrigin(),
  820.             'public',
  821.             $nodeVersion->getCreated()
  822.         );
  823.         $nodeTranslation->setPublicNodeVersion($publicNodeVersion);
  824.         $nodeVersion->setType('draft');
  825.         $nodeVersion->setOrigin($publicNodeVersion);
  826.         $nodeVersion->setCreated(new \DateTime());
  827.         $this->em->persist($nodeTranslation);
  828.         $this->em->persist($nodeVersion);
  829.         $this->em->flush();
  830.         $this->dispatch(
  831.             new NodeEvent(
  832.                 $nodeTranslation->getNode(),
  833.                 $nodeTranslation,
  834.                 $nodeVersion,
  835.                 $page
  836.             ),
  837.             Events::CREATE_DRAFT_VERSION
  838.         );
  839.         return $nodeVersion;
  840.     }
  841.     /**
  842.      * @param Node   $node       The node
  843.      * @param string $permission The permission to check for
  844.      *
  845.      * @throws AccessDeniedException
  846.      */
  847.     private function checkPermission(Node $node, $permission)
  848.     {
  849.         if (false === $this->authorizationChecker->isGranted($permission, $node)) {
  850.             throw new AccessDeniedException();
  851.         }
  852.     }
  853.     /**
  854.      * @param EntityManager   $em       The Entity Manager
  855.      * @param BaseUser        $user     The user who deletes the children
  856.      * @param string          $locale   The locale that was used
  857.      * @param ArrayCollection $children The children array
  858.      */
  859.     private function deleteNodeChildren(
  860.         EntityManager $em,
  861.         BaseUser $user,
  862.         $locale,
  863.         ArrayCollection $children,
  864.     ) {
  865.         /* @var Node $childNode */
  866.         foreach ($children as $childNode) {
  867.             $childNodeTranslation = $childNode->getNodeTranslation(
  868.                 $this->locale,
  869.                 true
  870.             );
  871.             $childNodeVersion = $childNodeTranslation->getPublicNodeVersion();
  872.             $childNodePage = $childNodeVersion->getRef($this->em);
  873.             $this->dispatch(
  874.                 new NodeEvent(
  875.                     $childNode,
  876.                     $childNodeTranslation,
  877.                     $childNodeVersion,
  878.                     $childNodePage
  879.                 ),
  880.                 Events::PRE_DELETE
  881.             );
  882.             $childNode->setDeleted(true);
  883.             $this->em->persist($childNode);
  884.             $children2 = $childNode->getChildren();
  885.             $this->deleteNodeChildren($em, $user, $locale, $children2);
  886.             $this->dispatch(
  887.                 new NodeEvent(
  888.                     $childNode,
  889.                     $childNodeTranslation,
  890.                     $childNodeVersion,
  891.                     $childNodePage
  892.                 ),
  893.                 Events::POST_DELETE
  894.             );
  895.         }
  896.     }
  897.     /**
  898.      * @param string $type
  899.      */
  900.     private function createNewPage(Request $request, $type): HasNodeInterface
  901.     {
  902.         /* @var HasNodeInterface $newPage */
  903.         $newPage = new $type();
  904.         $title = $request->request->get('title');
  905.         if (\is_string($title) && !empty($title)) {
  906.             $newPage->setTitle($title);
  907.         } else {
  908.             $newPage->setTitle($this->container->get('translator')->trans('kuma_node.admin.new_page.title.default'));
  909.         }
  910.         $this->em->persist($newPage);
  911.         $this->em->flush();
  912.         return $newPage;
  913.     }
  914.     /**
  915.      * @param Request $request
  916.      *
  917.      * @throw InvalidArgumentException
  918.      */
  919.     private function validatePageType($request): string
  920.     {
  921.         $type = $request->request->get('type') ?? $request->query->get('type');
  922.         if (empty($type)) {
  923.             throw new \InvalidArgumentException('Please specify a type of page you want to create');
  924.         }
  925.         return $type;
  926.     }
  927.     private function renderNodeNotTranslatedPage(Node $node): Response
  928.     {
  929.         // try to find a parent node with the correct translation, if there is none allow copy.
  930.         // if there is a parent but it doesn't have the language to copy to don't allow it
  931.         $parentNode = $node->getParent();
  932.         if ($parentNode) {
  933.             $parentNodeTranslation = $parentNode->getNodeTranslation(
  934.                 $this->locale,
  935.                 true
  936.             );
  937.             $parentsAreOk = false;
  938.             if ($parentNodeTranslation) {
  939.                 $parentsAreOk = $this->em->getRepository(
  940.                     NodeTranslation::class
  941.                 )->hasParentNodeTranslationsForLanguage(
  942.                     $node->getParent()->getNodeTranslation(
  943.                         $this->locale,
  944.                         true
  945.                     ),
  946.                     $this->locale
  947.                 );
  948.             }
  949.         } else {
  950.             $parentsAreOk = true;
  951.         }
  952.         return $this->render('@KunstmaanNode/NodeAdmin/pagenottranslated.html.twig', [
  953.             'node' => $node,
  954.             'nodeTranslations' => $node->getNodeTranslations(true),
  955.             'copyfromotherlanguages' => $parentsAreOk,
  956.         ]);
  957.     }
  958.     /**
  959.      * @param object $event
  960.      */
  961.     private function dispatch($event, string $eventName): object
  962.     {
  963.         return $this->container->get('event_dispatcher')->dispatch($event, $eventName);
  964.     }
  965.     public static function getSubscribedServices(): array
  966.     {
  967.         return [
  968.             'security.authorization_checker' => AuthorizationCheckerInterface::class,
  969.             'kunstmaan_admin.acl.helper' => AclHelper::class,
  970.             'kunstmaan_admin.acl.manager' => AclManager::class,
  971.             'kunstmaan_node.admin_node.publisher' => NodeAdminPublisher::class,
  972.             PageCloningHelper::class => PageCloningHelper::class,
  973.             'kunstmaan_node.acl_permission_creator_service' => ACLPermissionCreatorService::class,
  974.             'form.factory' => FormFactoryInterface::class,
  975.             'kunstmaan_adminlist.factory' => AdminListFactory::class,
  976.             'kunstmaan_admin.clone.helper' => CloneHelper::class,
  977.             'request_stack' => RequestStack::class,
  978.             'kunstmaan_node.actions_menu_builder' => ActionsMenuBuilder::class,
  979.             'kunstmaan_node.admin_node.node_version_lock_helper' => NodeVersionLockHelper::class,
  980.             'translator' => TranslatorInterface::class,
  981.             'event_dispatcher' => EventDispatcherInterface::class,
  982.         ] + parent::getSubscribedServices();
  983.     }
  984. }