• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP Mapping\ClassMetadata类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中Doctrine\Common\Persistence\Mapping\ClassMetadata的典型用法代码示例。如果您正苦于以下问题:PHP ClassMetadata类的具体用法?PHP ClassMetadata怎么用?PHP ClassMetadata使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



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

示例1: readExtendedMetadata

 /**
  * {@inheritDoc}
  */
 public function readExtendedMetadata(ClassMetadata $meta, array &$config)
 {
     $class = $meta->getReflectionClass();
     // class annotations
     if ($annot = $this->reader->getClassAnnotation($class, self::LOGGABLE)) {
         $config['loggable'] = true;
         if ($annot->logEntryClass) {
             if (!class_exists($annot->logEntryClass)) {
                 throw new InvalidMappingException("LogEntry class: {$annot->logEntryClass} does not exist.");
             }
             $config['logEntryClass'] = $annot->logEntryClass;
         }
     }
     // property annotations
     foreach ($class->getProperties() as $property) {
         if ($meta->isMappedSuperclass && !$property->isPrivate() || $meta->isInheritedField($property->name) || isset($meta->associationMappings[$property->name]['inherited'])) {
             continue;
         }
         // versioned property
         if ($versioned = $this->reader->getPropertyAnnotation($property, self::VERSIONED)) {
             $field = $property->getName();
             if ($meta->isCollectionValuedAssociation($field)) {
                 throw new InvalidMappingException("Cannot versioned [{$field}] as it is collection in object - {$meta->name}");
             }
             // fields cannot be overrided and throws mapping exception
             $config['versioned'][] = $field;
         }
     }
 }
开发者ID:robertowest,项目名称:CuteFlow-V4,代码行数:32,代码来源:Annotation.php


示例2: readExtendedMetadata

 /**
  * {@inheritDoc}
  */
 public function readExtendedMetadata(ClassMetadata $meta, array &$config)
 {
     $class = $meta->getReflectionClass();
     // property annotations
     $config['fields'] = array();
     $config['fields_delete'] = array();
     foreach ($class->getProperties() as $property) {
         if ($meta->isMappedSuperclass && !$property->isPrivate() || $meta->isInheritedField($property->name) || isset($meta->associationMappings[$property->name]['inherited'])) {
             continue;
         }
         $field = null;
         if ($file = $this->reader->getPropertyAnnotation($property, self::FILE)) {
             $field['name'] = $property->getName();
             $field['dir'] = CMSCore::init()->getUploadsDir() . '/' . $file->dir;
             if (!$meta->hasField($field['name'])) {
                 throw new InvalidMappingException("Unable to find timestampable [{$field}] as mapped property in entity - {$meta->name}");
             }
         }
         // if ($fileDelete = $this->reader->getPropertyAnnotation($property, self::FILE_DELETE)) {
         //
         // $config['fields_delete'][] = $property->getName();
         //
         // }
         if ($field) {
             $config['fields'][] = $field;
         }
     }
 }
开发者ID:GrifiS,项目名称:Symfony2CMS,代码行数:31,代码来源:Annotation.php


示例3: getTransformerInfo

 /**
  * {@inheritdoc}
  */
 public function getTransformerInfo(ColumnInfoInterface $columnInfo, ClassMetadata $metadata)
 {
     if ($this->class !== $metadata->getName() || !$columnInfo->getAttribute() || $this->backendType !== $columnInfo->getAttribute()->getBackendType()) {
         return;
     }
     return array($this->transformer, array());
 }
开发者ID:javiersantos,项目名称:pim-community-dev,代码行数:10,代码来源:AttributeGuesser.php


示例4: unserialize

 public function unserialize($value, ClassMetadata $metadata, $field)
 {
     $array = array();
     $serializerMetadata = $metadata->getSerializer();
     //reset value to array
     if (!is_array($value)) {
         if ($value instanceof ArrayCollection) {
             $value = $value->toArray();
         } elseif ($value instanceof ArrayObject) {
             $value = $value->getArrayCopy();
         }
     }
     if (isset($serializerMetadata['fields'][$field]['collectionType'])) {
         switch ($serializerMetadata['fields'][$field]['collectionType']) {
             case 'ArrayObject':
                 $array = new ArrayObject($value);
                 break;
             case 'ArrayCollection':
                 $array = new ArrayCollection($value);
                 break;
             case 'Array':
             case 'array':
             default:
                 $array = $value;
                 break;
         }
     } else {
         $array = (array) $value;
     }
     return $array;
 }
开发者ID:zoopcommerce,项目名称:shard,代码行数:31,代码来源:Collection.php


示例5: loadMetadataForClass

 /**
  * Loads the metadata for the specified class into the provided container.
  *
  * @param string        $className
  * @param ClassMetadata $metadata
  */
 public function loadMetadataForClass($className, ClassMetadata $metadata)
 {
     $class = $metadata->getReflectionClass();
     if (!$class) {
         // this happens when running annotation driver in combination with
         // static reflection services. This is not the nicest fix
         $class = new \ReflectionClass($metadata->name);
     }
     $entityAnnot = $this->reader->getClassAnnotation($class, 'Doctrine\\KeyValueStore\\Mapping\\Annotations\\Entity');
     if (!$entityAnnot) {
         throw new \InvalidArgumentException($metadata->name . ' is not a valid key-value-store entity.');
     }
     $metadata->storageName = $entityAnnot->storageName;
     // Evaluate annotations on properties/fields
     foreach ($class->getProperties() as $property) {
         $idAnnot = $this->reader->getPropertyAnnotation($property, 'Doctrine\\KeyValueStore\\Mapping\\Annotations\\Id');
         $transientAnnot = $this->reader->getPropertyAnnotation($property, 'Doctrine\\KeyValueStore\\Mapping\\Annotations\\Transient');
         if ($idAnnot) {
             $metadata->mapIdentifier($property->getName());
         } elseif ($transientAnnot) {
             $metadata->skipTransientField($property->getName());
         } else {
             $metadata->mapField(['fieldName' => $property->getName()]);
         }
     }
 }
开发者ID:nicktacular,项目名称:KeyValueStore,代码行数:32,代码来源:AnnotationDriver.php


示例6: getTransformerInfo

 /**
  * {@inheritdoc}
  */
 public function getTransformerInfo(ColumnInfoInterface $columnInfo, ClassMetadata $metadata)
 {
     if (!$metadata->hasField($columnInfo->getPropertyPath()) || $this->type != $metadata->getTypeOfField($columnInfo->getPropertyPath())) {
         return;
     }
     return array($this->transformer, array());
 }
开发者ID:noglitchyo,项目名称:pim-community-dev,代码行数:10,代码来源:TypeGuesser.php


示例7: let

 /**
  * @param \Symfony\Component\DependencyInjection\ContainerInterface $container
  * @param \Doctrine\Common\Persistence\ManagerRegistry $doctrine
  * @param \Doctrine\Common\Persistence\ObjectManager $manager
  * @param \Behat\Behat\Hook\Scope\ScenarioScope $event
  * @param \Behat\Gherkin\Node\FeatureNode $feature
  * @param \Behat\Gherkin\Node\ScenarioNode $scenario
  * @param \Knp\FriendlyContexts\Alice\Loader\Yaml $loader
  * @param \Doctrine\Common\Persistence\Mapping\ClassMetadataFactory $metadataFactory
  * @param \Doctrine\Common\Persistence\Mapping\ClassMetadata $userMetadata
  * @param \Doctrine\Common\Persistence\Mapping\ClassMetadata $placeMetadata
  * @param \Doctrine\Common\Persistence\Mapping\ClassMetadata $productMetadata
  */
 function let($container, $doctrine, $manager, $event, $loader, $feature, $scenario, $metadataFactory, $userMetadata, $placeMetadata, $productMetadata)
 {
     $doctrine->getManager()->willReturn($manager);
     $feature->getTags()->willReturn(['alice(Place)', 'admin']);
     $scenario->getTags()->willReturn(['alice(User)']);
     $event->getFeature()->willReturn($feature);
     $event->getScenario()->willReturn($scenario);
     $loader->load('user.yml')->willReturn([]);
     $loader->load('product.yml')->willReturn([]);
     $loader->load('place.yml')->willReturn([]);
     $loader->getCache()->willReturn([]);
     $loader->clearCache()->willReturn(null);
     $fixtures = ['User' => 'user.yml', 'Product' => 'product.yml', 'Place' => 'place.yml'];
     $config = ['alice' => ['fixtures' => $fixtures, 'dependencies' => []]];
     $container->has(Argument::any())->willReturn(true);
     $container->hasParameter(Argument::any())->willReturn(true);
     $container->get('friendly.alice.loader.yaml')->willReturn($loader);
     $container->get('doctrine')->willReturn($doctrine);
     $container->getParameter('friendly.alice.fixtures')->willReturn($fixtures);
     $container->getParameter('friendly.alice.dependencies')->willReturn([]);
     $manager->getMetadataFactory()->willReturn($metadataFactory);
     $metadataFactory->getAllMetadata()->willReturn([$userMetadata, $placeMetadata, $productMetadata]);
     $userMetadata->getName()->willReturn('User');
     $placeMetadata->getName()->willReturn('Place');
     $productMetadata->getName()->willReturn('Product');
     $this->initialize($config, $container);
 }
开发者ID:benji07,项目名称:FriendlyContexts,代码行数:40,代码来源:AliceContextSpec.php


示例8: loadMetadataForClass

 /**
  * Loads the metadata for the specified class into the provided container.
  *
  * @param string $className
  * @param CommonClassMetadata $metadata
  *
  * @return void
  */
 public function loadMetadataForClass($className, CommonClassMetadata $metadata)
 {
     /** @var \Doctrine\KeyValueStore\Mapping\ClassMetadata $metadata */
     try {
         $element = $this->getElement($className);
     } catch (MappingException $exception) {
         throw new \InvalidArgumentException($metadata->name . ' is not a valid key-value-store entity.');
     }
     $class = new \ReflectionClass($className);
     if (isset($element['storageName'])) {
         $metadata->storageName = $element['storageName'];
     }
     $ids = [];
     if (isset($element['id'])) {
         $ids = $element['id'];
     }
     $transients = [];
     if (isset($element['transient'])) {
         $transients = $element['transient'];
     }
     foreach ($class->getProperties() as $property) {
         if (in_array($property->getName(), $ids)) {
             $metadata->mapIdentifier($property->getName());
             continue;
         }
         if (in_array($property->getName(), $transients)) {
             $metadata->skipTransientField($property->getName());
             continue;
         }
         $metadata->mapField(array('fieldName' => $property->getName()));
     }
 }
开发者ID:kevinyien,项目名称:KeyValueStore,代码行数:40,代码来源:YamlDriver.php


示例9: getEntityFields

 protected function getEntityFields(ClassMetadata $metaData, array $data)
 {
     // change data keys to camelcase
     $result = array();
     foreach ($data as $key => $value) {
         // convert to camelcase if underscore is in name
         if (strpos($key, '_') !== false) {
             $key = implode('', array_map('ucfirst', explode('_', $key)));
         }
         $result[$key] = $value;
     }
     $data = $result;
     // get all fields
     $fieldNames = $metaData->getFieldNames();
     $fields = array();
     foreach ($fieldNames as $fieldName) {
         if (!isset($data[$fieldName])) {
             continue;
         }
         $type = $metaData->getTypeOfField($fieldName);
         $value = $this->getColumnTypeValue($type, $data[$fieldName]);
         $fields[$fieldName] = $value;
     }
     return $fields;
 }
开发者ID:seytar,项目名称:psx,代码行数:25,代码来源:Entity.php


示例10: getTransformerInfo

 /**
  * {@inheritdoc}
  */
 public function getTransformerInfo(ColumnInfoInterface $columnInfo, ClassMetadata $metadata)
 {
     if (!$metadata->hasField($columnInfo->getPropertyPath())) {
         return;
     }
     return [$this->transformer, []];
 }
开发者ID:abdeldayem,项目名称:pim-community-dev,代码行数:10,代码来源:DefaultGuesser.php


示例11: getTransformerInfo

 /**
  * {@inheritdoc}
  */
 public function getTransformerInfo(ColumnInfoInterface $columnInfo, ClassMetadata $metadata)
 {
     if (!$columnInfo->getLocale() && !count($columnInfo->getSuffixes()) || !$metadata->hasAssociation('translations')) {
         return;
     }
     return array($this->transformer, array());
 }
开发者ID:noglitchyo,项目名称:pim-community-dev,代码行数:10,代码来源:TranslationGuesser.php


示例12: isResource

 /**
  * @param ClassMetadata $metadata
  *
  * @return bool
  */
 protected function isResource(ClassMetadata $metadata)
 {
     if (!($reflClass = $metadata->getReflectionClass())) {
         return false;
     }
     return $reflClass->implementsInterface(PersistableInterface::class);
 }
开发者ID:superdesk,项目名称:web-publisher,代码行数:12,代码来源:AbstractDoctrineSubscriber.php


示例13: 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:robertowest,项目名称:CuteFlow-V4,代码行数:35,代码来源:Annotation.php


示例14: readExtendedMetadata

 /**
  * {@inheritDoc}
  */
 public function readExtendedMetadata(ClassMetadata $meta, array &$config)
 {
     $mapping = $this->_getMapping($meta->name);
     if (isset($mapping['gedmo'])) {
         $classMapping = $mapping['gedmo'];
         if (isset($classMapping['loggable'])) {
             $config['loggable'] = true;
             if (isset($classMapping['loggable']['logEntryClass'])) {
                 if (!class_exists($classMapping['loggable']['logEntryClass'])) {
                     throw new InvalidMappingException("LogEntry class: {$classMapping['loggable']['logEntryClass']} does not exist.");
                 }
                 $config['logEntryClass'] = $classMapping['loggable']['logEntryClass'];
             }
         }
     }
     if (isset($mapping['fields'])) {
         foreach ($mapping['fields'] as $field => $fieldMapping) {
             if (isset($fieldMapping['gedmo'])) {
                 if (in_array('versioned', $fieldMapping['gedmo'])) {
                     if ($meta->isCollectionValuedAssociation($field)) {
                         throw new InvalidMappingException("Cannot versioned [{$field}] as it is collection in object - {$meta->name}");
                     }
                     // fields cannot be overrided and throws mapping exception
                     $config['versioned'][] = $field;
                 }
             }
         }
     }
 }
开发者ID:rdohms,项目名称:DoctrineExtensions,代码行数:32,代码来源:Yaml.php


示例15: isIgnoredInWorkflow

 /**
  * Checks if the given relation should be ignored in workflows
  *
  * @param ClassMetadata $metadata
  * @param string        $associationName
  *
  * @return bool
  */
 protected function isIgnoredInWorkflow(ClassMetadata $metadata, $associationName)
 {
     if ($this->isWorkflowField($associationName)) {
         return true;
     }
     return !$metadata->isSingleValuedAssociation($associationName);
 }
开发者ID:northdakota,项目名称:platform,代码行数:15,代码来源:FieldProvider.php


示例16: appendConfigurationFromMetadata

 protected function appendConfigurationFromMetadata(ClassMetadata $metadata, &$configuration)
 {
     $serializationFilePath = $this->resolvePath($metadata->getReflectionClass());
     if ($this->filesystem->exists($serializationFilePath)) {
         $content = file_get_contents($serializationFilePath);
         $configuration = array_replace_recursive($configuration, $this->parseContent($content));
     }
 }
开发者ID:wellcommerce,项目名称:wellcommerce,代码行数:8,代码来源:SerializationCacheWarmer.php


示例17: initializeReflection

 /**
  * Initializes Reflection after ClassMetadata was constructed.
  *
  * @param ClassMetadata     $class
  * @param ReflectionService $reflService
  *
  * @return void
  */
 protected function initializeReflection(ClassMetadata $class, ReflectionService $reflService)
 {
     if (!$class instanceof EntityMetadata) {
         throw new \LogicException('Metadata is not supported');
     }
     /** @var EntityMetadata $class */
     $class->initializeReflection($reflService);
 }
开发者ID:bankiru,项目名称:doctrine-api-client,代码行数:16,代码来源:EntityMetadataFactory.php


示例18: getDateValue

 /**
  * {@inheritDoc}
  */
 public function getDateValue(ClassMetadata $meta, $field)
 {
     $mapping = $meta->getFieldMapping($field);
     if (isset($mapping['type']) && $mapping['type'] === 'timestamp') {
         return time();
     }
     return new \DateTime();
 }
开发者ID:robertowest,项目名称:CuteFlow-V4,代码行数:11,代码来源:ODM.php


示例19: getTransformerInfo

 /**
  * {@inheritdoc}
  */
 public function getTransformerInfo(ColumnInfoInterface $columnInfo, ClassMetadata $metadata)
 {
     $mapping = $this->getMapping();
     if (!$metadata->hasAssociation('translations') || !isset($mapping[$columnInfo->getName()])) {
         return null;
     }
     return array($this->transformer, array('propertyPath' => $mapping[$columnInfo->getName()]));
 }
开发者ID:noglitchyo,项目名称:pim-community-dev,代码行数:11,代码来源:NestedTranslationGuesser.php


示例20: initializeReflection

 protected function initializeReflection(ClassMetadata $class, ReflectionService $reflService)
 {
     $class->reflClass = $reflService->getClass($class->name);
     if ($class->reflClass) {
         foreach ($class->reflClass->getProperties() as $property) {
             $class->mapField(['fieldName' => $property->getName()]);
         }
     }
 }
开发者ID:nicktacular,项目名称:KeyValueStore,代码行数:9,代码来源:ClassMetadataFactory.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP Util\ClassUtils类代码示例发布时间:2022-05-23
下一篇:
PHP Event\LifecycleEventArgs类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap