當前位置: 首頁>>代碼示例>>PHP>>正文


PHP ClassMetadata::skipTransientField方法代碼示例

本文整理匯總了PHP中Doctrine\Common\Persistence\Mapping\ClassMetadata::skipTransientField方法的典型用法代碼示例。如果您正苦於以下問題:PHP ClassMetadata::skipTransientField方法的具體用法?PHP ClassMetadata::skipTransientField怎麽用?PHP ClassMetadata::skipTransientField使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Doctrine\Common\Persistence\Mapping\ClassMetadata的用法示例。


在下文中一共展示了ClassMetadata::skipTransientField方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: 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

示例2: 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

示例3: 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)
 {
     try {
         $xmlRoot = $this->getElement($className);
     } catch (MappingException $exception) {
         throw new \InvalidArgumentException($metadata->name . ' is not a valid key-value-store entity.');
     }
     if ($xmlRoot->getName() != 'entity') {
         throw new \InvalidArgumentException($metadata->name . ' is not a valid key-value-store entity.');
     }
     $class = new \ReflectionClass($className);
     if (isset($xmlRoot['storage-name'])) {
         $metadata->storageName = $xmlRoot['storage-name'];
     }
     $ids = [];
     if (isset($xmlRoot->id)) {
         foreach ($xmlRoot->id as $id) {
             $ids[] = (string) $id;
         }
     }
     $transients = [];
     if (isset($xmlRoot->transient)) {
         foreach ($xmlRoot->transient as $transient) {
             $transients[] = (string) $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,代碼行數:46,代碼來源:XmlDriver.php


注:本文中的Doctrine\Common\Persistence\Mapping\ClassMetadata::skipTransientField方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。