当前位置: 首页>>代码示例>>PHP>>正文


PHP AnnotationReader::setAnnotationNamespaceAlias方法代码示例

本文整理汇总了PHP中Doctrine\Common\Annotations\AnnotationReader::setAnnotationNamespaceAlias方法的典型用法代码示例。如果您正苦于以下问题:PHP AnnotationReader::setAnnotationNamespaceAlias方法的具体用法?PHP AnnotationReader::setAnnotationNamespaceAlias怎么用?PHP AnnotationReader::setAnnotationNamespaceAlias使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Doctrine\Common\Annotations\AnnotationReader的用法示例。


在下文中一共展示了AnnotationReader::setAnnotationNamespaceAlias方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: readExtendedMetadata

 /**
  * (non-PHPdoc)
  * @see Gedmo\Mapping.Driver::readExtendedMetadata()
  */
 public function readExtendedMetadata(ClassMetadataInfo $meta, array &$config)
 {
     require_once __DIR__ . '/../Annotations.php';
     $reader = new AnnotationReader();
     $reader->setAnnotationNamespaceAlias('Gedmo\\Timestampable\\Mapping\\', 'gedmo');
     $class = $meta->getReflectionClass();
     // property annotations
     foreach ($class->getProperties() as $property) {
         if ($meta->isMappedSuperclass && !$property->isPrivate() || $meta->isInheritedField($property->name) || $meta->isInheritedAssociation($property->name)) {
             continue;
         }
         if ($timestampable = $reader->getPropertyAnnotation($property, self::ANNOTATION_TIMESTAMPABLE)) {
             $field = $property->getName();
             if (!$meta->hasField($field)) {
                 throw MappingException::fieldMustBeMapped($field, $meta->name);
             }
             if (!$this->_isValidField($meta, $field)) {
                 throw MappingException::notValidFieldType($field, $meta->name);
             }
             if (!in_array($timestampable->on, array('update', 'create', 'change'))) {
                 throw MappingException::triggerTypeInvalid($field, $meta->name);
             }
             if ($timestampable->on == 'change') {
                 if (!isset($timestampable->field) || !isset($timestampable->value)) {
                     throw MappingException::parametersMissing($field, $meta->name);
                 }
                 $field = array('field' => $field, 'trackedField' => $timestampable->field, 'value' => $timestampable->value);
             }
             // properties are unique and mapper checks that, no risk here
             $config[$timestampable->on][] = $field;
         }
     }
 }
开发者ID:jgat2012,项目名称:hp_oms,代码行数:37,代码来源:Annotation.php

示例2: setUp

 public function setUp()
 {
     if (version_compare(\Doctrine\Common\Version::VERSION, '2.1.0RC4-DEV', '>=')) {
         $this->markTestSkipped('Doctrine common is 2.1.0RC4-DEV version, skipping.');
     } else {
         if (version_compare(\Doctrine\Common\Version::VERSION, '2.1.0-BETA3-DEV', '>=')) {
             $reader = new AnnotationReader();
             $reader->setDefaultAnnotationNamespace('Doctrine\\ORM\\Mapping\\');
             $reader->setIgnoreNotImportedAnnotations(true);
             $reader->setAnnotationNamespaceAlias('Gedmo\\Mapping\\Annotation\\', 'gedmo');
             $reader->setEnableParsePhpImports(false);
             $reader->setAutoloadAnnotations(true);
             $reader = new CachedReader(new \Doctrine\Common\Annotations\IndexedReader($reader), new ArrayCache());
         } else {
             $reader = new AnnotationReader();
             $reader->setAutoloadAnnotations(true);
             $reader->setAnnotationNamespaceAlias('Gedmo\\Mapping\\Annotation\\', 'gedmo');
             $reader->setDefaultAnnotationNamespace('Doctrine\\ORM\\Mapping\\');
         }
     }
     $config = new \Doctrine\ORM\Configuration();
     $config->setProxyDir(TESTS_TEMP_DIR);
     $config->setProxyNamespace('Gedmo\\Mapping\\Proxy');
     $config->setMetadataDriverImpl(new AnnotationDriver($reader));
     $conn = array('driver' => 'pdo_sqlite', 'memory' => true);
     //$config->setSQLLogger(new \Doctrine\DBAL\Logging\EchoSQLLogger());
     $evm = new \Doctrine\Common\EventManager();
     $this->timestampable = new \Gedmo\Timestampable\TimestampableListener();
     $evm->addEventSubscriber($this->timestampable);
     $this->em = \Doctrine\ORM\EntityManager::create($conn, $config, $evm);
     $schemaTool = new \Doctrine\ORM\Tools\SchemaTool($this->em);
     $schemaTool->dropSchema(array());
     $schemaTool->createSchema(array($this->em->getClassMetadata(self::ARTICLE)));
 }
开发者ID:robertowest,项目名称:CuteFlow-V4,代码行数:34,代码来源:CompatibilityMappingTest.php

示例3: readExtendedMetadata

 public function readExtendedMetadata(ClassMetadata $meta, array &$config)
 {
     // load our available annotations
     require_once __DIR__ . '/../Annotations.php';
     $reader = new AnnotationReader();
     // set annotation namespace and alias
     $reader->setAnnotationNamespaceAlias('Gedmo\\Mapping\\Mock\\Extension\\Encoder\\Mapping\\', 'ext');
     $class = $meta->getReflectionClass();
     // check only property annotations
     foreach ($class->getProperties() as $property) {
         // skip inherited properties
         if ($meta->isMappedSuperclass && !$property->isPrivate() || $meta->isInheritedField($property->name) || isset($meta->associationMappings[$property->name]['inherited'])) {
             continue;
         }
         // now lets check if property has our annotation
         if ($encode = $reader->getPropertyAnnotation($property, 'Gedmo\\Mapping\\Mock\\Extension\\Encoder\\Mapping\\Encode')) {
             $field = $property->getName();
             // check if field is mapped
             if (!$meta->hasField($field)) {
                 throw new \Exception("Field is not mapped as object property");
             }
             // allow encoding only strings
             if (!in_array($encode->type, array('sha1', 'md5'))) {
                 throw new \Exception("Invalid encoding type supplied");
             }
             // validate encoding type
             $mapping = $meta->getFieldMapping($field);
             if ($mapping['type'] != 'string') {
                 throw new \Exception("Only strings can be encoded");
             }
             // store the metadata
             $config['encode'][$field] = array('type' => $encode->type, 'secret' => $encode->secret);
         }
     }
 }
开发者ID:rdohms,项目名称:DoctrineExtensions,代码行数:35,代码来源:Annotation.php

示例4: readExtendedMetadata

 /**
  * (non-PHPdoc)
  * @see Gedmo\Mapping.Driver::readExtendedMetadata()
  */
 public function readExtendedMetadata(ClassMetadataInfo $meta, array &$config)
 {
     require_once __DIR__ . '/../Annotations.php';
     $reader = new AnnotationReader();
     $reader->setAnnotationNamespaceAlias('Gedmo\\Tree\\Mapping\\', 'gedmo');
     $class = $meta->getReflectionClass();
     // property annotations
     foreach ($class->getProperties() as $property) {
         if ($meta->isMappedSuperclass && !$property->isPrivate() || $meta->isInheritedField($property->name) || $meta->isInheritedAssociation($property->name)) {
             continue;
         }
         // left
         if ($left = $reader->getPropertyAnnotation($property, self::ANNOTATION_LEFT)) {
             $field = $property->getName();
             if (!$meta->hasField($field)) {
                 throw MappingException::fieldMustBeMapped($field, $meta->name);
             }
             if (!$this->_isValidField($meta, $field)) {
                 throw MappingException::notValidFieldType($field, $meta->name);
             }
             $config['left'] = $field;
         }
         // right
         if ($right = $reader->getPropertyAnnotation($property, self::ANNOTATION_RIGHT)) {
             $field = $property->getName();
             if (!$meta->hasField($field)) {
                 throw MappingException::fieldMustBeMapped($field, $meta->name);
             }
             if (!$this->_isValidField($meta, $field)) {
                 throw MappingException::notValidFieldType($field, $meta->name);
             }
             $config['right'] = $field;
         }
         // ancestor/parent
         if ($parent = $reader->getPropertyAnnotation($property, self::ANNOTATION_PARENT)) {
             $field = $property->getName();
             if (!$meta->isSingleValuedAssociation($field)) {
                 throw MappingException::parentFieldNotMappedOrRelated($field, $meta->name);
             }
             $config['parent'] = $field;
         }
         // level
         if ($parent = $reader->getPropertyAnnotation($property, self::ANNOTATION_LEVEL)) {
             $field = $property->getName();
             if (!$meta->hasField($field)) {
                 throw MappingException::fieldMustBeMapped($field, $meta->name);
             }
             if (!$this->_isValidField($meta, $field)) {
                 throw MappingException::notValidFieldType($field, $meta->name);
             }
             $config['level'] = $field;
         }
     }
 }
开发者ID:jgat2012,项目名称:hp_oms,代码行数:58,代码来源:Annotation.php

示例5: readExtendedMetadata

 /**
  * (non-PHPdoc)
  * @see Gedmo\Mapping.Driver::readExtendedMetadata()
  */
 public function readExtendedMetadata(ClassMetadataInfo $meta, array &$config)
 {
     require_once __DIR__ . '/../Annotations.php';
     $reader = new AnnotationReader();
     $reader->setAnnotationNamespaceAlias('Gedmo\\Translatable\\Mapping\\', 'gedmo');
     $class = $meta->getReflectionClass();
     // class annotations
     $classAnnotations = $reader->getClassAnnotations($class);
     if (isset($classAnnotations[self::ANNOTATION_ENTITY_CLASS])) {
         $annot = $classAnnotations[self::ANNOTATION_ENTITY_CLASS];
         if (!class_exists($annot->class)) {
             throw MappingException::translationClassNotFound($annot->class);
         }
         $config['translationClass'] = $annot->class;
     }
     // property annotations
     foreach ($class->getProperties() as $property) {
         if ($meta->isMappedSuperclass && !$property->isPrivate() || $meta->isInheritedField($property->name) || $meta->isInheritedAssociation($property->name)) {
             continue;
         }
         // translatable property
         if ($translatable = $reader->getPropertyAnnotation($property, self::ANNOTATION_TRANSLATABLE)) {
             $field = $property->getName();
             if (!$meta->hasField($field)) {
                 throw MappingException::fieldMustBeMapped($field, $meta->name);
             }
             if (!$this->_isValidField($meta, $field)) {
                 throw MappingException::notValidFieldType($field, $meta->name);
             }
             // fields cannot be overrided and throws mapping exception
             $config['fields'][] = $field;
         }
         // locale property
         if ($locale = $reader->getPropertyAnnotation($property, self::ANNOTATION_LOCALE)) {
             $field = $property->getName();
             if ($meta->hasField($field)) {
                 throw MappingException::fieldMustNotBeMapped($field, $meta->name);
             }
             $config['locale'] = $field;
         } elseif ($language = $reader->getPropertyAnnotation($property, self::ANNOTATION_LANGUAGE)) {
             $field = $property->getName();
             if ($meta->hasField($field)) {
                 throw MappingException::fieldMustNotBeMapped($field, $meta->name);
             }
             $config['locale'] = $field;
         }
     }
 }
开发者ID:jgat2012,项目名称:hp_oms,代码行数:52,代码来源:Annotation.php

示例6: readExtendedMetadata

 /**
  * (non-PHPdoc)
  * @see Gedmo\Mapping.Driver::readExtendedMetadata()
  */
 public function readExtendedMetadata(ClassMetadataInfo $meta, array &$config)
 {
     require_once __DIR__ . '/../Annotations.php';
     $reader = new AnnotationReader();
     $reader->setAnnotationNamespaceAlias('Gedmo\\Sluggable\\Mapping\\', 'gedmo');
     $class = $meta->getReflectionClass();
     // property annotations
     foreach ($class->getProperties() as $property) {
         if ($meta->isMappedSuperclass && !$property->isPrivate() || $meta->isInheritedField($property->name) || $meta->isInheritedAssociation($property->name)) {
             continue;
         }
         // sluggable property
         if ($sluggable = $reader->getPropertyAnnotation($property, self::ANNOTATION_SLUGGABLE)) {
             $field = $property->getName();
             if (!$meta->hasField($field)) {
                 throw MappingException::fieldMustBeMapped($field, $meta->name);
             }
             if (!$this->_isValidField($meta, $field)) {
                 throw MappingException::notValidFieldType($field, $meta->name);
             }
             $config['fields'][] = $field;
         }
         // slug property
         if ($slug = $reader->getPropertyAnnotation($property, self::ANNOTATION_SLUG)) {
             $field = $property->getName();
             if (!$meta->hasField($field)) {
                 throw MappingException::slugFieldMustBeMapped($field, $meta->name);
             }
             if (!$this->_isValidField($meta, $field)) {
                 throw MappingException::notValidFieldType($field, $meta->name);
             }
             if (isset($config['slug'])) {
                 throw MappingException::slugFieldIsDuplicate($field, $meta->name);
             }
             $config['slug'] = $field;
             $config['style'] = $slug->style;
             $config['updatable'] = $slug->updatable;
             $config['unique'] = $slug->unique;
             $config['separator'] = $slug->separator;
         }
     }
 }
开发者ID:jgat2012,项目名称:hp_oms,代码行数:46,代码来源:Annotation.php

示例7: getDefaultAnnotationReader

 /**
  * Create default annotation reader for extensions
  *
  * @return \Doctrine\Common\Annotations\AnnotationReader
  */
 private function getDefaultAnnotationReader()
 {
     if (null === self::$defaultAnnotationReader) {
         if (version_compare(\Doctrine\Common\Version::VERSION, '2.2.0-DEV', '>=')) {
             $reader = new \Doctrine\Common\Annotations\AnnotationReader();
             \Doctrine\Common\Annotations\AnnotationRegistry::registerAutoloadNamespace('Gedmo\\Mapping\\Annotation', __DIR__ . '/../../');
             $reader = new \Doctrine\Common\Annotations\CachedReader($reader, new ArrayCache());
         } else {
             if (version_compare(\Doctrine\Common\Version::VERSION, '2.1.0RC4-DEV', '>=')) {
                 $reader = new \Doctrine\Common\Annotations\AnnotationReader();
                 \Doctrine\Common\Annotations\AnnotationRegistry::registerAutoloadNamespace('Gedmo\\Mapping\\Annotation', __DIR__ . '/../../');
                 $reader->setDefaultAnnotationNamespace('Doctrine\\ORM\\Mapping\\');
                 $reader = new \Doctrine\Common\Annotations\CachedReader($reader, new ArrayCache());
             } else {
                 if (version_compare(\Doctrine\Common\Version::VERSION, '2.1.0-BETA3-DEV', '>=')) {
                     $reader = new \Doctrine\Common\Annotations\AnnotationReader();
                     $reader->setDefaultAnnotationNamespace('Doctrine\\ORM\\Mapping\\');
                     $reader->setIgnoreNotImportedAnnotations(true);
                     $reader->setAnnotationNamespaceAlias('Gedmo\\Mapping\\Annotation\\', 'gedmo');
                     $reader->setEnableParsePhpImports(false);
                     $reader->setAutoloadAnnotations(true);
                     $reader = new \Doctrine\Common\Annotations\CachedReader(new \Doctrine\Common\Annotations\IndexedReader($reader), new ArrayCache());
                 } else {
                     $reader = new \Doctrine\Common\Annotations\AnnotationReader();
                     $reader->setAutoloadAnnotations(true);
                     $reader->setAnnotationNamespaceAlias('Gedmo\\Mapping\\Annotation\\', 'gedmo');
                     $reader->setDefaultAnnotationNamespace('Doctrine\\ORM\\Mapping\\');
                 }
             }
         }
         self::$defaultAnnotationReader = $reader;
     }
     return self::$defaultAnnotationReader;
 }
开发者ID:pabloasc,项目名称:test_social,代码行数:39,代码来源:MappedEventSubscriber.php

示例8: loadDoctrineConfiguration

 public function loadDoctrineConfiguration(Application $app)
 {
     $app['doctrine.configuration'] = $app->share(function () use($app) {
         if (isset($app['doctrine.orm']) and true === $app['doctrine.orm']) {
             $config = new ORMConfiguration();
             $cache = new ApcCache();
             $config->setMetadataCacheImpl($cache);
             $config->setQueryCacheImpl($cache);
             $chain = new DriverChain();
             foreach ((array) $app['doctrine.orm.entities'] as $entity) {
                 switch ($entity['type']) {
                     case 'annotation':
                         $reader = new AnnotationReader();
                         $reader->setAnnotationNamespaceAlias('Doctrine\\ORM\\Mapping\\', 'orm');
                         $driver = new AnnotationDriver($reader, (array) $entity['path']);
                         $chain->addDriver($driver, $entity['namespace']);
                         break;
                     case 'yml':
                         $driver = new YamlDriver((array) $entity['path']);
                         $driver->setFileExtension('.yml');
                         $chain->addDriver($driver, $entity['namespace']);
                         break;
                     case 'xml':
                         $driver = new XmlDriver((array) $entity['path'], $entity['namespace']);
                         $driver->setFileExtension('.xml');
                         $chain->addDriver($driver, $entity['namespace']);
                         break;
                     default:
                         throw new \InvalidArgumentException(sprintf('"%s" is not a recognized driver', $type));
                         break;
                 }
             }
             $config->setMetadataDriverImpl($chain);
             $config->setProxyDir($app['doctrine.orm.proxies_dir']);
             $config->setProxyNamespace($app['doctrine.orm.proxies_namespace']);
             $config->setAutoGenerateProxyClasses($app['doctrine.orm.auto_generate_proxies']);
         } else {
             $config = new DBALConfiguration();
         }
         return $config;
     });
 }
开发者ID:estudiofaz,项目名称:hotel-reservation-website,代码行数:42,代码来源:DoctrineExtension.php

示例9: __construct

 /**
  * Build the AnnotationLoader with an AnnotationReader
  *
  * @param AnnotationReader $reader
  */
 public function __construct(AnnotationReader $reader)
 {
     $this->reader = $reader;
     $this->reader->setAutoloadAnnotations(true);
     $this->reader->setAnnotationNamespaceAlias('Hitch\\Mapping\\Annotation\\', 'xml');
 }
开发者ID:kustov-vitalik,项目名称:xml-hitch,代码行数:11,代码来源:AnnotationLoader.php


注:本文中的Doctrine\Common\Annotations\AnnotationReader::setAnnotationNamespaceAlias方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。