예제 #1
0
 protected function doInjection($instance, $className)
 {
     $propertiesAnnotations = $this->annotationManager->getPropertiesAnnotations($className);
     foreach ($propertiesAnnotations as $propertyName => $annotations) {
         if (isset($annotations['Inject'])) {
             /** @var \A7\Annotations\Inject $inject */
             $inject = $annotations['Inject'];
             $reflectionProperty = new \ReflectionProperty($instance, $propertyName);
             $reflectionProperty->setAccessible(true);
             if (isset($annotations['var'])) {
                 $inject->setVar($annotations['var']);
             }
             $inject->isInjectObject();
             if ($inject->isInjectObject()) {
                 $reflectionProperty->setValue($instance, $this->a7->get($inject->getName()));
             } else {
                 $name = $inject->getName();
                 if (isset($name) && isset($this->parameters[$name])) {
                     $reflectionProperty->setValue($instance, $this->parameters[$name]);
                 }
             }
         }
     }
     return $instance;
 }
예제 #2
0
파일: A7.php 프로젝트: ArmineKhachatryan/A7
 protected function isLazy($class)
 {
     $injectable = $this->annotationManager->getClassAnnotation($class, 'Injectable');
     /** @var Injectable $injectable */
     $injectable = !isset($injectable) ? new Injectable() : $injectable;
     return $injectable->lazy;
 }