コード例 #1
0
 /**
  * Loads an internal Service.
  *
  * @param string $name Internal service name
  * @return Bisna\Service\AbstractService
  */
 public function getInternalService($name)
 {
     $serviceContext = $this->context->lookup($name);
     $serviceConfig = $serviceContext['config'];
     // Throw exception if service is not internal
     if (!(isset($serviceConfig['internal']) && $serviceConfig['internal'])) {
         throw new Exception\InvalidServiceException("Unable to initialize external service '{$serviceContext['class']}' through an internal call.");
     }
     return $this->loadService($serviceContext);
 }
コード例 #2
0
 /**
  * Retrieve context of a given service name.
  * 
  * @param string $name Service name
  * 
  * @return array
  */
 private function getServiceContext($name)
 {
     $serviceContext = $this->context->lookup($name);
     // Throw an exception if service not found
     if (!is_array($serviceContext)) {
         throw new Exception\InvalidServiceException("Unable to locate service '" . $name . "'.");
     }
     $classParents = class_parents($serviceContext['class']);
     // Throw exception if service is not service
     if (!in_array('Bisna\\Service\\Service', $classParents)) {
         throw new Exception\InvalidServiceException("Unable to initialize a non service '{$serviceContext['class']}'.");
     }
     return $serviceContext;
 }