vendor/kunstmaan/form-bundle/EventListener/ConfigureActionsMenuListener.php line 40

Open in your IDE?
  1. <?php
  2. namespace Kunstmaan\FormBundle\EventListener;
  3. use Doctrine\ORM\EntityManager;
  4. use Kunstmaan\FormBundle\Entity\AbstractFormPage;
  5. use Kunstmaan\NodeBundle\Event\ConfigureActionMenuEvent;
  6. use Symfony\Component\Routing\RouterInterface;
  7. /**
  8.  * An event listener to add a formsubmissions link to the submenu of nodes.
  9.  */
  10. class ConfigureActionsMenuListener
  11. {
  12.     /**
  13.      * @var EntityManager
  14.      */
  15.     private $em;
  16.     /**
  17.      * @var Router
  18.      */
  19.     private $router;
  20.     /**
  21.      * @param EntityManager   $em     The entity manager
  22.      * @param RouterInterface $router The router
  23.      */
  24.     public function __construct(EntityManager $emRouterInterface $router)
  25.     {
  26.         $this->router $router;
  27.         $this->em $em;
  28.     }
  29.     /**
  30.      * Configure the form submissions link on top of the form in the sub action menu
  31.      *
  32.      * @param ConfigureActionMenuEvent $event
  33.      */
  34.     public function onSubActionMenuConfigure(ConfigureActionMenuEvent $event)
  35.     {
  36.         $menu $event->getMenu();
  37.         $activeNodeVersion $event->getActiveNodeVersion();
  38.         if (!is_null($activeNodeVersion)) {
  39.             $page $activeNodeVersion->getRef($this->em);
  40.             if ($page instanceof AbstractFormPage) {
  41.                 $activeNodeTranslation $activeNodeVersion->getNodeTranslation();
  42.                 $menu->addChild('subaction.formsubmissions', array('uri' => $this->router->generate('KunstmaanFormBundle_formsubmissions_list', array('nodeTranslationId' => $activeNodeTranslation->getId()))));
  43.             }
  44.         }
  45.     }
  46. }