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


PHP ClassMetadata::getReflectionClass方法代码示例

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


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

示例1: convertMetadata

 /**
  * @param ClassMetadata $metadata
  * @return JavaScript\Metadata
  */
 private function convertMetadata(ClassMetadata $metadata)
 {
     $meta = new JavaScript\Metadata();
     $meta->originalName = $metadata->getName();
     $meta->namespace = str_replace('\\', '_', $metadata->getReflectionClass()->getNamespaceName());
     $meta->functionName = $metadata->getReflectionClass()->getShortName();
     $parent = $metadata->getReflectionClass()->getParentClass();
     $meta->superFunctionName = $parent ? $parent->getShortName() : 'DBEntity';
     // Convert fields.
     foreach ($metadata->getFieldNames() as $fieldName) {
         $field = new JavaScript\Field();
         $field->name = $fieldName;
         $field->methodName = ucfirst($fieldName);
         $field->type = $this->convertDoctrineType($metadata->getTypeOfField($fieldName));
         $field->isIdentifier = $metadata->isIdentifier($fieldName);
         $meta->fields[] = $field;
     }
     // Convert associations.
     foreach ($metadata->getAssociationNames() as $assocName) {
         $assoc = new JavaScript\Association();
         $assoc->name = $assocName;
         $assoc->methodName = ucfirst($assocName);
         $assoc->isCollection = $metadata->isCollectionValuedAssociation($assocName);
         $assoc->isSingle = $metadata->isSingleValuedAssociation($assocName);
         $assoc->singleName = Inflector::singularize($assoc->methodName);
         $assoc->invertedField = $metadata->getAssociationMappedByTargetField($assocName);
         $targetClass = new \ReflectionClass($metadata->getAssociationTargetClass($assocName));
         $assoc->singleType = $targetClass->getShortName();
         $assoc->type = $assoc->singleType . ($assoc->isCollection ? '[]' : '');
         $meta->associations[] = $assoc;
     }
     return $meta;
 }
开发者ID:CornyPhoenix,项目名称:JsEntitiesBundle,代码行数:37,代码来源:JsEntityConverter.php

示例2: initialise

 public function initialise($container)
 {
     $this->manager = $container->get('doctrine')->getManager();
     $this->ormMetadata = $this->manager->getClassMetadata($this->entityName);
     $this->class = $this->ormMetadata->getReflectionClass()->name;
     $mapping = $container->get('grid.mapping.manager');
     /** todo autoregister mapping drivers with tag */
     $mapping->addDriver($this, -1);
     $this->metadata = $mapping->getMetadata($this->class);
 }
开发者ID:sxn,项目名称:DataGridBundle,代码行数:10,代码来源:Entity.php

示例3: __construct

 /**
  * {@inheritdoc}
  */
 public function __construct(EntityManager $em, ClassMetadata $class)
 {
     if ($class->getReflectionClass()->isSubclassOf('Gedmo\\Translatable\\Entity\\MappedSuperclass\\AbstractPersonalTranslation')) {
         throw new \Gedmo\Exception\UnexpectedValueException('This repository is useless for personal translations');
     }
     parent::__construct($em, $class);
 }
开发者ID:n1c01a5,项目名称:DoctrineExtensions,代码行数:10,代码来源:TranslationRepository.php

示例4: getResult

 /**
  * {@inheritdoc}
  */
 public function getResult(ClassMetadata $classMetadata, array $options = [])
 {
     $cmsEntity = $this->reader->getClassAnnotation($classMetadata->getReflectionClass(), 'Sentient\\Cms\\Data\\Metadata\\Annotation\\CmsEntity');
     if (!empty($cmsEntity->slug)) {
         return $cmsEntity->slug;
     }
     return $this->entityNameQuery->getResult($classMetadata);
 }
开发者ID:mikegibson,项目名称:sentient,代码行数:11,代码来源:GetCmsEntitySlugQuery.php

示例5: getResult

 public function getResult(ClassMetadata $classMetadata, array $options = [])
 {
     $annotation = $this->reader->getClassAnnotation($classMetadata->getReflectionClass(), $this->annotationClass);
     if (is_a($annotation, $this->annotationClass)) {
         return $annotation;
     }
     return $this->getFallbackResult($classMetadata, $options);
 }
开发者ID:mikegibson,项目名称:sentient,代码行数:8,代码来源:GetEntityCrudQuery.php

示例6: getResult

 public function getResult(ClassMetadata $classMetadata, array $options = [])
 {
     $reflClass = $classMetadata->getReflectionClass();
     $annotation = $this->reader->getClassAnnotation($reflClass, $this->annotationClass);
     if (!empty($annotation->value)) {
         return $annotation->value;
     }
     return $this->getFallbackResult($classMetadata, $options);
 }
开发者ID:mikegibson,项目名称:sentient,代码行数:9,代码来源:GetEntityNameQuery.php

示例7: initialise

 public function initialise($container)
 {
     $doctrine = $container->get('doctrine');
     $this->manager = version_compare(Kernel::VERSION, '2.1.0', '>=') ? $doctrine->getManager($this->managerName) : $doctrine->getEntityManager($this->managerName);
     $this->ormMetadata = $this->manager->getClassMetadata($this->entityName);
     $this->class = $this->ormMetadata->getReflectionClass()->name;
     $mapping = $container->get('grid.mapping.manager');
     /** todo autoregister mapping drivers with tag */
     $mapping->addDriver($this, -1);
     $this->metadata = $mapping->getMetadata($this->class, $this->group);
     $this->groupBy = $this->metadata->getGroupBy();
 }
开发者ID:radzikowski,项目名称:APYDataGridBundle,代码行数:12,代码来源:Entity.php

示例8: getResult

 public function getResult(ClassMetadata $classMetadata, array $options = [])
 {
     $annotation = $this->reader->getClassAnnotation($classMetadata->getReflectionClass(), $this->annotationClass);
     if (!is_a($annotation, $this->annotationClass)) {
         $humanized = $this->getFallbackResult($classMetadata, $options);
     } else {
         $humanized = empty($options['plural']) ? $annotation->singular : $annotation->plural;
     }
     if (!empty($options['capitalize'])) {
         $humanized = $this->capitalize($humanized);
     }
     return $humanized;
 }
开发者ID:mikegibson,项目名称:sentient,代码行数:13,代码来源:GetEntityHumanNameQuery.php

示例9: getResult

 public function getResult(ClassMetadata $classMetadata, array $options = [])
 {
     foreach (['property', 'annotationClass'] as $key) {
         if (!isset($options[$key])) {
             throw new \InvalidArgumentException(sprintf('The %s option was not specified.', $key));
         }
     }
     $options = array_merge(['checkGetter' => true, 'checkSetter' => true], $options);
     $reflClass = $classMetadata->getReflectionClass();
     $annotation = null;
     if ($reflClass->hasProperty($options['property'])) {
         $property = $classMetadata->getReflectionClass()->getProperty($options['property']);
         $annotation = $this->reader->getPropertyAnnotation($property, $options['annotationClass']);
     }
     if ($annotation === null) {
         $methods = [];
         if ($options['checkGetter']) {
             $methods[] = 'get' . ucfirst($options['property']);
         }
         if ($options['checkSetter']) {
             $methods[] = 'set' . ucfirst($options['property']);
         }
         foreach ($methods as $name) {
             if (!$reflClass->hasMethod($name)) {
                 continue;
             }
             $method = $reflClass->getMethod($name);
             if (!$method->isPublic()) {
                 continue;
             }
             $annotation = $this->reader->getMethodAnnotation($method, $options['annotationClass']);
             if ($annotation !== null) {
                 break;
             }
         }
     }
     return $annotation;
 }
开发者ID:mikegibson,项目名称:sentient,代码行数:38,代码来源:GetPropertyAnnotationQuery.php

示例10: getResult

 public function getResult(ClassMetadata $classMetadata, array $options = [])
 {
     $create = !isset($options['create']) || $options['create'];
     $editableProperties = [];
     foreach ($classMetadata->getReflectionClass()->getMethods(\ReflectionMethod::IS_PUBLIC) as $reflMethod) {
         if (!preg_match('/^set([A-Z][A-Za-z0-9]+)$/', $reflMethod->getName(), $matches)) {
             continue;
         }
         $property = lcfirst($matches[1]);
         if ($this->isPropertyEditableQuery->getResult($classMetadata, compact('property', 'create'))) {
             $editableProperties[] = $property;
         }
     }
     return $editableProperties;
 }
开发者ID:mikegibson,项目名称:sentient,代码行数:15,代码来源:GetEditablePropertiesQuery.php

示例11: getResult

 public function getResult(ClassMetadata $classMetadata, array $options = [])
 {
     $important = !empty($options['important']);
     $visibleProperties = [];
     foreach ($classMetadata->getReflectionClass()->getMethods(\ReflectionMethod::IS_PUBLIC) as $reflMethod) {
         if (!preg_match('/^get([A-Z][A-Za-z0-9]+)$/', $reflMethod->getName(), $matches)) {
             continue;
         }
         $property = lcfirst($matches[1]);
         if ($this->isPropertyVisibleQuery->getResult($classMetadata, compact('property', 'important'))) {
             $visibleProperties[] = $property;
         }
     }
     return $visibleProperties;
 }
开发者ID:mikegibson,项目名称:sentient,代码行数:15,代码来源:GetVisiblePropertiesQuery.php

示例12: getResourceType

 public static function getResourceType($entityManager, ClassMetadata $meta, $level = 0)
 {
     if (isset(self::$resourceTypes[$meta->getName()])) {
         return self::$resourceTypes[$meta->getName()];
     }
     $refClass = $meta->getReflectionClass();
     $namespace = null;
     $resourceType = new ResourceType($refClass, ResourceTypeKind::ENTITY, $refClass->getShortName(), $namespace);
     $addedProperties = array();
     foreach ($meta->fieldMappings as $fieldName => $data) {
         $type = $resourceType->getPrimitiveResourceType(DataTypeMapper::fromDoctrineToOData($data['type']));
         $kind = ResourcePropertyKind::PRIMITIVE;
         $resourceProperty = new ResourceProperty($fieldName, null, $kind, $type);
         $resourceType->addProperty($resourceProperty);
         $addedProperties[$fieldName] = $resourceProperty;
     }
     if ($level < self::LEVEL_MAX) {
         foreach ($meta->associationMappings as $fieldName => $data) {
             if ($associationMeta = $entityManager->getClassMetadata($data['targetEntity'])) {
                 $type = self::getResourceType($entityManager, $associationMeta, self::$level++);
                 $kind = ResourcePropertyKind::RESOURCE_REFERENCE;
                 $resourceProperty = new ResourceProperty($fieldName, null, $kind, $type);
                 $resourceType->addProperty($resourceProperty);
                 $fkFieldName = self::getForeignKeyFieldName($data, $entityManager);
                 if (!$fkFieldName) {
                     $fkFieldName = $data['fieldName'] . 'Id';
                 }
                 if ($fkFieldName) {
                     if (!isset($addedProperties[$fkFieldName])) {
                         //*
                         $type = $resourceType->getPrimitiveResourceType(DataTypeMapper::fromDoctrineToOData('integer'));
                         $kind = ResourcePropertyKind::PRIMITIVE;
                         $resourceProperty = new ResourceProperty($fkFieldName, null, $kind, $type);
                         $resourceType->addProperty($resourceProperty);
                         $addedProperties[$fieldName] = $resourceProperty;
                         //*/
                     }
                 }
                 //                        break;
             }
         }
     }
     self::$level = 1;
     return self::$resourceTypes[$meta->getName()] = $resourceType;
 }
开发者ID:s001dxp,项目名称:breeze.server.php,代码行数:45,代码来源:ResourceType.php

示例13: createProxyFile

 private function createProxyFile(ClassMetadata $classMetadata)
 {
     $fileName = str_replace('\\', '_', $classMetadata->getName());
     $reflection = $classMetadata->getReflectionClass();
     $filecontent = $this->getFileContent($classMetadata->getName());
     foreach ($reflection->getProperties() as $property) {
         /* @var $property \ReflectionProperty */
         $annotation = $this->getPropertyAnnotation($property);
         if (!is_null($annotation)) {
             $filecontent .= '        $obj->' . $property->getName() . ' = ' . $annotation->getFixture() . "\n";
         }
     }
     foreach ($classMetadata->getAssociationMappings() as $association) {
         $filecontent .= '        $obj->' . $association['fieldName'] . ' = array_key_exists("' . $association['fieldName'] . '", $dpdc) ? $dpdc["' . $association['fieldName'] . '"] : null;' . "\n";
     }
     $filecontent .= '        return $obj;' . "\n" . '    }' . "\n" . '}';
     file_put_contents($this->_cacheDir . DIRECTORY_SEPARATOR . $fileName, $filecontent);
 }
开发者ID:mickaelsteinberg,项目名称:BackBee,代码行数:18,代码来源:Fixture.php

示例14: extendLoadMetadataForClass

 /**
  * Merge DoctrineClassMetadata and DataAuditClassMetadata
  * @param  DoctrineClassMetadata $doctrineClassMetadata
  * @return null|ClassMetadata
  * @throws \InvalidArgumentException
  */
 public function extendLoadMetadataForClass(DoctrineClassMetadata $doctrineClassMetadata)
 {
     if ($doctrineClassMetadata->isMappedSuperclass || !($classMetadata = $this->loadMetadataForClass($doctrineClassMetadata->getReflectionClass()))) {
         return null;
     }
     /** @var $property PropertyMetadata */
     foreach ($classMetadata->propertyMetadata as $name => $property) {
         if ($doctrineClassMetadata->isInheritedField($name) || isset($doctrineClassMetadata->associationMappings[$property->name]['inherited'])) {
             unset($classMetadata->propertyMetadata[$name]);
             continue;
         }
         if ($doctrineClassMetadata->isCollectionValuedAssociation($name)) {
             $property->isCollection = true;
             $targetMapping = $doctrineClassMetadata->getAssociationMapping($name);
             if (!method_exists($targetMapping['targetEntity'], $property->method)) {
                 throw new \InvalidArgumentException(sprintf("Method %s in Class %s is not defined. Class must implement " . "a method '__toString' or configure getMethod with Versioned annotation", $property->method, $targetMapping['targetEntity']));
             }
         }
     }
     return $classMetadata;
 }
开发者ID:Maksold,项目名称:platform,代码行数:27,代码来源:AnnotationDriver.php

示例15: __construct

 public function __construct(Reader $reader, ClassMetadata $meta)
 {
     $reflect = $meta->getReflectionClass();
     $class_name = $reflect->getName();
     $this->class_name = $class_name;
     self::addAnnotation($reader->getClassAnnotations($reflect), $this->class_annotations, $class_name, true);
     foreach ($reflect->getProperties() as $p) {
         $property_name = $p->getName();
         if (in_array(strtolower($property_name), self::$sql_keys)) {
             throw new \Exception(sprintf("`%s->%s` use SQL key words as name", $class_name, $property_name));
         }
         $this->propertie_annotations[$property_name] = array();
         self::addAnnotation($reader->getPropertyAnnotations($p), $this->propertie_annotations[$property_name], sprintf("%s->%s", $class_name, $property_name));
         if (count($this->propertie_annotations[$property_name]) < 1) {
             unset($this->propertie_annotations[$property_name]);
         }
     }
     /*
             if( $this->class_name === 'Symforce\AdminBundle\Entity\Page' ) {
        \Dev::dump($this, 4 );
             }
     */
 }
开发者ID:symforce,项目名称:symforce-admin,代码行数:23,代码来源:AnnotationCache.php


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