本文整理汇总了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;
}
示例2: isFrozen
public function isFrozen($document, ClassMetadata $metadata)
{
return $metadata->getFieldValue($document, $metadata->getFreeze()['flag']);
}
示例3: isSoftDeleted
public function isSoftDeleted($document, ClassMetadata $metadata)
{
return $metadata->getFieldValue($document, $metadata->getSoftDelete()['flag']);
}
示例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();
}
}
}