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

setFieldValue() public method

Sets the specified field to the specified value on the given document.
public setFieldValue ( object $document, string $field, mixed $value )
$document object
$field string
$value mixed
    public function setFieldValue($document, $field, $value)
    {
        $this->reflFields[$field]->setValue($document, $value);
    }

Usage Example

Example #1
0
 private function resolveParent($document, ClassMetadata $metadata)
 {
     if (!($parentField = $metadata->parentMapping)) {
         throw new \RuntimeException(sprintf('A default parent path has been specified, but no parent mapping has been applied to document "%s"', get_class($document)));
     }
     if (false === $this->force) {
         $actualParent = $metadata->getFieldValue($document, $parentField);
         if ($actualParent) {
             return;
         }
     }
     $parentDocument = $this->documentManager->find(null, $this->parentPath);
     if (true === $this->autocreate && null === $parentDocument) {
         NodeHelper::createPath($this->documentManager->getPhpcrSession(), $this->parentPath);
         $parentDocument = $this->documentManager->find(null, $this->parentPath);
     }
     if (null === $parentDocument) {
         throw new \RuntimeException(sprintf('Document at default parent path "%s" does not exist. `autocreate` was set to "%s"', $this->parentPath, $this->autocreate ? 'true' : 'false'));
     }
     $metadata->setFieldValue($document, $parentField, $parentDocument);
 }
All Usage Examples Of Doctrine\ODM\PHPCR\Mapping\ClassMetadata::setFieldValue
ClassMetadata