/** * {@inheritdoc} * * @return bool|FormEvent|void * @throws \Symfony\Component\HttpKernel\Exception\MethodNotAllowedHttpException */ protected function dispatchEvent($action, &$entity, $isNew = false, Event $event = null) { if (!$entity instanceof Form) { throw new MethodNotAllowedHttpException(array('Form')); } switch ($action) { case "pre_save": $name = FormEvents::FORM_PRE_SAVE; break; case "post_save": $name = FormEvents::FORM_POST_SAVE; break; case "pre_delete": $name = FormEvents::FORM_PRE_DELETE; break; case "post_delete": $name = FormEvents::FORM_POST_DELETE; break; default: return null; } if ($this->dispatcher->hasListeners($name)) { if (empty($event)) { $event = new FormEvent($entity, $isNew); $event->setEntityManager($this->em); } $this->dispatcher->dispatch($name, $event); return $event; } else { return null; } }