Doctrine\ODM\PHPCR\Mapping\ClassMetadata::getFieldValue PHP Method

getFieldValue() public method

Gets the specified field's value off the given document.
public getFieldValue ( object $document, string $field ) : mixed | null
$document object the document to get the field from
$field string the name of the field
return mixed | null the value of this field for the document or null if not found
    public function getFieldValue($document, $field)
    {
        if (isset($this->reflFields[$field])) {
            return $this->reflFields[$field]->getValue($document);
        }
        return null;
    }

Usage Example

Ejemplo n.º 1
0
 /**
  * Use the name and parent fields to generate the id
  *
  * {@inheritDoc}
  */
 public function generate($document, ClassMetadata $class, DocumentManager $dm, $parent = null)
 {
     if (null === $parent) {
         $parent = $class->parentMapping ? $class->getFieldValue($document, $class->parentMapping) : null;
     }
     $name = $class->nodename ? $class->getFieldValue($document, $class->nodename) : null;
     $id = $class->getFieldValue($document, $class->identifier);
     if (empty($id)) {
         if (empty($name) && empty($parent)) {
             throw IdException::noIdentificationParameters($document, $class->parentMapping, $class->nodename);
         }
         if (empty($parent)) {
             throw IdException::noIdNoParent($document, $class->parentMapping);
         }
         if (empty($name)) {
             throw IdException::noIdNoName($document, $class->nodename);
         }
     }
     // use assigned ID by default
     if (empty($parent) || empty($name)) {
         return $id;
     }
     if ($exception = $class->isValidNodename($name)) {
         throw IdException::illegalName($document, $class->nodename, $name);
     }
     // determine ID based on the path and the node name
     return $this->buildName($document, $class, $dm, $parent, $name);
 }
All Usage Examples Of Doctrine\ODM\PHPCR\Mapping\ClassMetadata::getFieldValue
ClassMetadata