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


PHP ClassMetadata::getFieldValue方法代碼示例

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


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

示例1: isValid

 /**
  *
  * @param  object  $document
  * @return boolean
  */
 public function isValid($document, ClassMetadata $metadata, ChangeSet $changeSet = null)
 {
     $result = new DocumentValidatorResult(['value' => true]);
     if (!($validatorMetadata = $metadata->getValidator())) {
         return $result;
     }
     // Field level validators
     if (isset($validatorMetadata['fields'])) {
         foreach ($validatorMetadata['fields'] as $field => $validatorDefinition) {
             //if a change set is provided, only validate fields that have changed
             if (isset($changeSet) && !$changeSet->hasField($field)) {
                 continue;
             }
             $result->addFieldResult($field, $this->getValidator($validatorDefinition)->isValid($metadata->getFieldValue($document, $field)));
         }
     }
     // Document level validators
     if (isset($validatorMetadata['document'])) {
         $result->addClassResult($this->getValidator($validatorMetadata['document'])->isValid($document));
     }
     return $result;
 }
開發者ID:zoopcommerce,項目名稱:shard,代碼行數:27,代碼來源:DocumentValidator.php

示例2: isFrozen

 public function isFrozen($document, ClassMetadata $metadata)
 {
     return $metadata->getFieldValue($document, $metadata->getFreeze()['flag']);
 }
開發者ID:zoopcommerce,項目名稱:shard,代碼行數:4,代碼來源:Freezer.php

示例3: isSoftDeleted

 public function isSoftDeleted($document, ClassMetadata $metadata)
 {
     return $metadata->getFieldValue($document, $metadata->getSoftDelete()['flag']);
 }
開發者ID:zoopcommerce,項目名稱:shard,代碼行數:4,代碼來源:SoftDeleter.php

示例4: findTranslation

 /**
  * Find translation entity by specified language using filter method from ArrayCollection class
  *
  * @param \Doctrine\Common\Collections\ArrayCollection $translates
  * @param \Doctrine\Common\Persistence\Mapping\ClassMetadata $translationMeta
  * @param string $translationLocaleField
  * @param mixed $locale
  *
  * @return ArrayCollection
  */
 private function findTranslation(Collection $translations, ClassMetadata $translationMeta, $translationLocaleField, $locale)
 {
     $translations = $translations->filter(function ($translation) use($locale, $translationMeta, $translationLocaleField) {
         $translationLocale = $translationMeta->getFieldValue($translation, $translationLocaleField);
         if ($translationLocale === $locale) {
             return true;
         } else {
             return false;
         }
     });
     if (!$translations->count()) {
         return null;
     } else {
         if ($translations->count() > 1) {
             throw new Exception\RuntimeException('Multiple translations found for one locale');
         } else {
             return $translations->first();
         }
     }
 }
開發者ID:byteincoffee,項目名稱:doctrine-extensions,代碼行數:30,代碼來源:TranslatableListener.php


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