Example #1
0
 /**
  * @param $property
  * @return mixed|null
  * @throws Exception
  */
 public function __get($property)
 {
     if (!is_object($this->dependencyInjector) || !$this->dependencyInjector instanceof ContainerInterface) {
         throw new Exception('A dependency injection object is required');
     }
     if ($this->dependencyInjector->has($property)) {
         $service = $this->dependencyInjector->get($property);
         $this->{$property} = $service;
         return $service;
     }
     return null;
 }
Example #2
0
 public function register(ContainerInterface $container)
 {
     if (null !== $this->getServiceName() && !$container->has($this->getServiceName())) {
         $container->set($this->getServiceName(), $this);
     }
 }