Exemplo n.º 1
0
 /**
  * @return array
  */
 public function getInjectorDeps(\ReflectionMethod $injector)
 {
     $result = [];
     foreach ($injector->getParameters() as $param) {
         $typeHinted = $param->getClass();
         if (!$typeHinted) {
             $result[] = null;
             continue;
         }
         $typeName = $typeHinted->name;
         $depClassName = null;
         if ($typeHinted->isInterface()) {
             $metaService = $this->metadriver->getMetaServiceByInterface($typeName);
             // some services can be optional. deactivate service if current event
             // is not in the list of its wake-up events
             if ($param->isOptional()) {
                 $this->deactivateService($metaService);
             }
             $depClassName = $metaService->getActiveFlag() ? $metaService->getClassName() : null;
         } else {
             if (AbstractService::isService($typeName)) {
                 $depClassName = $typeName;
             }
         }
         $result[] = $depClassName;
     }
     return $result;
 }
Exemplo n.º 2
0
 /**
  * @return object
  */
 public function create($className, $factoryArgs = [])
 {
     $fqcn = $this->nameResolver->resolve($className);
     if (AbstractService::isService($fqcn)) {
         return $this->createService($fqcn, $factoryArgs);
     } else {
         return $this->createObject($fqcn, $factoryArgs);
     }
 }