Example #1
0
 /**
  * {@inheritdoc}
  *
  * @throws \Symfony\Component\HttpKernel\Exception\MethodNotAllowedHttpException
  */
 protected function dispatchEvent($action, &$entity, $isNew = false, Event $event = null)
 {
     if (!$entity instanceof Page) {
         throw new MethodNotAllowedHttpException(array('Page'));
     }
     switch ($action) {
         case 'pre_save':
             $name = PageEvents::PAGE_PRE_SAVE;
             break;
         case 'post_save':
             $name = PageEvents::PAGE_POST_SAVE;
             break;
         case 'pre_delete':
             $name = PageEvents::PAGE_PRE_DELETE;
             break;
         case 'post_delete':
             $name = PageEvents::PAGE_POST_DELETE;
             break;
         default:
             return null;
     }
     if ($this->dispatcher->hasListeners($name)) {
         if (empty($event)) {
             $event = new PageEvent($entity, $isNew);
             $event->setEntityManager($this->em);
         }
         $this->dispatcher->dispatch($name, $event);
         return $event;
     }
     return null;
 }