Exemplo n.º 1
0
 /**
  * Dispatch events
  * @param \Reflector $reflector
  * @param $eventNameBase
  */
 private function dispatchEventForAnnotation(\Reflector $reflector, $eventNameBase)
 {
     $annotationReader = $this->getSphringEventDispatcher()->getSphringBoot()->getSphringAnnotationReader();
     if ($reflector instanceof \ReflectionClass) {
         $annotationsArray = $annotationReader->getClassAnnotations($reflector);
     } else {
         $annotationsArray = $annotationReader->getMethodAnnotations($reflector);
     }
     if (empty($annotationsArray)) {
         return;
     }
     $toReturn = null;
     foreach ($annotationsArray as $annotation) {
         $eventName = $eventNameBase . strtolower(ClassName::getShortName($annotation));
         $event = new EventAnnotation();
         $event->setData($annotation);
         $event->setBean($this->bean);
         $event->setReflector($reflector);
         $event->setMethodArgs($this->methodArgs);
         $event->setName($eventName);
         $this->sphringEventDispatcher->dispatch($eventName, $event);
         $this->methodArgs = $event->getMethodArgs();
         if ($annotation != $event->getData()) {
             $toReturn = $event->getData();
         }
     }
     $this->toReturn = $toReturn;
 }
Exemplo n.º 2
0
 /**
  * @param string $propertyKey
  * @param mixed $propertyValue
  * @throws \Arthurh\Sphring\Exception\BeanException
  * @return AbstractBeanProperty
  */
 protected function getPropertyFromEvent($propertyKey, $propertyValue)
 {
     if (!isset($propertyValue)) {
         throw new BeanException($this, "property not valid");
     }
     $event = new EventBeanProperty();
     $event->setData($propertyValue);
     $eventName = SphringEventEnum::PROPERTY_INJECTION . $propertyKey;
     $event->setName($eventName);
     $event = $this->sphringEventDispatcher->dispatch($eventName, $event);
     if (!$event instanceof EventBeanProperty) {
         throw new BeanException($this, "event '%s' is not a '%s' event", get_class($event), EventBeanProperty::class);
     }
     return $event->getBeanProperty();
 }
Exemplo n.º 3
0
 /**
  *
  */
 public function clear()
 {
     $this->sphringEventDispatcher->dispatch(SphringEventEnum::SPHRING_CLEAR, new EventSphring($this));
     $this->context = array();
     $this->beans = array();
 }