getName() public method

Return a name of class
public getName ( ) : null | string
return null | string
コード例 #1
0
 public function handleClassAnnotation(Service $annotation, ClassScanner $class)
 {
     if (!$annotation->getName()) {
         $annotation->setName($class->getName());
     }
     switch ($annotation->getType()) {
         case 'invokable':
             $this->definitions[$annotation->getServiceManager()]['invokables'][$annotation->getName()] = $class->getName();
             break;
         case 'factory':
             if (!in_array(FactoryInterface::class, $class->getInterfaces())) {
                 throw new InvalidAnnotationException('Service factory class must implement "' . FactoryInterface::class . '".');
             }
             $this->definitions[$annotation->getServiceManager()]['factories'][$annotation->getName()] = $class->getName();
             break;
         case 'abstractFactory':
             if (!in_array(AbstractFactoryInterface::class, $class->getInterfaces())) {
                 throw new InvalidAnnotationException('Abstract service factory class must implement "' . AbstractFactoryInterface::class . '".');
             }
             $this->definitions[$annotation->getServiceManager()]['abstract_factories'][] = $class->getName();
             break;
         case 'initializer':
             if (!in_array(InitializerInterface::class, $class->getInterfaces())) {
                 throw new InvalidAnnotationException('Initializer must implement "' . InitializerInterface::class . '".');
             }
             $this->definitions[$annotation->getServiceManager()]['initializers'][] = $class->getName();
             break;
         case 'delegator':
             if (!in_array(DelegatorFactoryInterface::class, $class->getInterfaces())) {
                 throw new InvalidAnnotationException('Delegator must implement "' . DelegatorFactoryInterface::class . '".');
             }
             if (empty($annotation->getFor())) {
                 throw new InvalidAnnotationException('Delegator annotation must contain "for" option.');
             }
             if (!isset($this->definitions[$annotation->getServiceManager()]['delegators'][$annotation->getFor()])) {
                 $this->definitions[$annotation->getServiceManager()]['delegators'][$annotation->getFor()] = array();
             }
             $this->definitions[$annotation->getServiceManager()]['delegators'][$annotation->getFor()][] = $class->getName();
             break;
         default:
             throw new InvalidAnnotationException('Service annotation must have "type" property value. Seen in ' . $class->getName());
     }
     $allowedToShareAndAlias = array('invokable', 'factory');
     if (in_array($annotation->getType(), $allowedToShareAndAlias)) {
         if (is_bool($annotation->getShared())) {
             $this->definitions[$annotation->getServiceManager()]['shared'][$annotation->getName()] = $annotation->getShared();
         }
         foreach ($annotation->getAliases() as $alias) {
             $this->definitions[$annotation->getServiceManager()]['aliases'][$alias] = $annotation->getName();
         }
     }
 }
コード例 #2
0
ファイル: Compiler.php プロジェクト: niallmccrudden/zf2
 public function compileScannerInjectionMethods(ClassScanner $scannerClass)
 {
     $data      = array();
     $className = $scannerClass->getName();
     foreach ($scannerClass->getMethods(true) as $scannerMethod) {
         $methodName = $scannerMethod->getName();
         
         // determine initiator & constructor dependencies
         if ($methodName === '__construct' && $scannerMethod->isPublic()) {
             $params = $scannerMethod->getParameters(true);
             if ($params) {
                 $data[$methodName] = array();
                 foreach ($params as $param) {
                     $data[$methodName][$param->getName()] = $param->getClass();
                 }
             }
         }
         
         // scan for setter injection
         if (preg_match('#^set[A-Z]#', $methodName)) {
             $data[$methodName] = $scannerMethod->getParameters();
             $params = $scannerMethod->getParameters(true);
             $data[$methodName] = array();
             foreach ($params as $param) {
                 $data[$methodName][$param->getName()] = $param->getClass();
             }
         }
     }
     return $data;
 }
コード例 #3
0
 /**
  * @param  int|string $methodNameOrInfoIndex
  * @return MethodScanner
  * @throws Exception\InvalidArgumentException
  */
 public function getMethod($methodNameOrInfoIndex)
 {
     if ($this->classScanner->hasMethod($methodNameOrInfoIndex)) {
         return $this->classScanner->getMethod($methodNameOrInfoIndex);
     }
     foreach ($this->parentClassScanners as $pClassScanner) {
         if ($pClassScanner->hasMethod($methodNameOrInfoIndex)) {
             return $pClassScanner->getMethod($methodNameOrInfoIndex);
         }
     }
     throw new Exception\InvalidArgumentException(sprintf('Method %s not found in %s', $methodNameOrInfoIndex, $this->classScanner->getName()));
 }
コード例 #4
0
 /**
  * @param ClassScanner $classScanner
  * @return array
  */
 protected function processClassAnnotations(ClassScanner $classScanner)
 {
     $result = array();
     $result['name'] = $classScanner->getName();
     foreach ($classScanner->getAnnotations($this->annotationManager) as $annotation) {
         if ($annotation instanceof Annotation\Service) {
             $result['path'] = $annotation->getPath();
             $result['collectionPath'] = $annotation->getCollectionPath();
         } else {
             if ($annotation instanceof Annotation\Entity) {
                 $result['repository'] = $annotation->getRepository();
             } else {
                 if ($annotation instanceof Annotation\XML) {
                     $result['rootElement'] = $annotation->getRootElement();
                 }
             }
         }
     }
     return $result;
 }
コード例 #5
0
 /**
  * @param AnnotationInterface $annotation
  * @param ClassScanner $class
  * @throws InvalidArgumentException
  */
 public function annotationToRouteConfig(AnnotationInterface $annotation, ClassScanner $class, MethodScanner $method = null)
 {
     $method = $method ?: 'index';
     $annotation = $this->guessMissingFields($annotation, $method, $class->getName());
     $routeConfig = $this->getRouteConfig($annotation);
     if ($annotation->getExtends()) {
         $tmp = array();
         $ref =& $this->getReferenceForPath(explode('/', $annotation->getExtends()), $tmp);
         $ref = $routeConfig;
         return $tmp;
     } else {
         return $routeConfig;
     }
 }