示例#1
0
 /**
  * Dispatch postupload event.
  *
  * @param string $sourcefile
  * @param string $targetfile
  */
 private function dispatchPostUploadEvent($sourcefile, $targetfile)
 {
     if (null !== $this->_application && null !== $this->_application->getEventDispatcher()) {
         $event = new \BackBee\Event\PostUploadEvent($sourcefile, $targetfile);
         $this->_application->getEventDispatcher()->dispatch('file.postupload', $event);
     }
 }
示例#2
0
 /**
  * Trigger a BackBee\Event\Event depending on the entity and event name.
  *
  * @access protected
  *
  * @param string    $eventName The doctrine event name
  * @param Object    $entity    The entity instance
  * @param EventArgs $eventArgs The doctrine event arguments
  */
 protected function _triggerEvent($eventName, $entity, $eventArgs)
 {
     if (null === $this->_application) {
         return;
     }
     $dispatcher = $this->_application->getEventDispatcher();
     if (null !== $dispatcher) {
         $dispatcher->triggerEvent($eventName, $entity, $eventArgs);
     }
 }
 protected function triggerEvent($name = 'render', $object = null, $render = null)
 {
     if (null === $this->application) {
         return;
     }
     $dispatcher = $this->application->getEventDispatcher();
     if (null !== $dispatcher) {
         $object = null !== $object ? $object : $this->getObject();
         $event = new RendererEvent($object, null === $render ? $this : array($this, $render));
         $dispatcher->triggerEvent($name, $object, null, $event);
     }
 }
示例#4
0
 /**
  * Returns the list of class content names used by one of schemes
  * Dynamically add a listener on descrimator.onflush event to RewritingListener.
  *
  * @return array
  */
 public function getDiscriminators()
 {
     if (null === $this->descriminators) {
         $this->descriminators = [];
         if (array_key_exists('_content_', $this->schemes)) {
             foreach (array_keys($this->schemes['_content_']) as $descriminator) {
                 $this->descriminators[] = 'BackBee\\ClassContent\\' . $descriminator;
                 if (null !== $this->application->getEventDispatcher()) {
                     $this->application->getEventDispatcher()->addListener(str_replace(NAMESPACE_SEPARATOR, '.', $descriminator) . '.onflush', ['BackBee\\Event\\Listener\\RewritingListener', 'onFlushContent']);
                 }
             }
         }
     }
     return $this->descriminators;
 }
示例#5
0
 /**
  * Handles an exception by trying to convert it to a Response.
  *
  * @param \Exception $e       An \Exception instance
  * @param Request    $request A Request instance
  * @param integer    $type    The type of the request
  *
  * @return Response A Response instance
  */
 private function handleException(\Exception $exception, Request $request, $type)
 {
     $event = new GetResponseForExceptionEvent($this, $request, $type, $exception);
     $this->application->getEventDispatcher()->dispatch(KernelEvents::EXCEPTION, $event);
     return $event->getResponse();
 }