Sets the ResourceSegment to the given property of the given document.

@param ResourceSegmentBehavior $document
@param PropertyMetadata $property
1142
private function persistDocument(ResourceSegmentBehavior $document, PropertyMetadata $property)
    {
        $document->getStructure()->getProperty(
            $property->getName()
        )->setValue($document->getResourceSegment());
    }
1066188
public function addTranslationData($entity, $propertyPath, $data)
    {
        $metadata = $this->metadataCollection->getMetadata($entity);
        $property = $metadata->getProperty($propertyPath);
        $strategy = $this->strategyResolver->getStrategy($property->getStrategy());
        $strategy->addTranslationData($entity, $property, $data, $metadata);
    }
356283
private function readProperty($property, $metadata)
    {
        $reflClass = $metadata->getReflectionClass();
        
        // Skip if this property is not from this class
        if ($property->getDeclaringClass()->getName()
            != $metadata->getClassName()
        ) {
            return;
        }

        //Iterate over all annotations
        foreach($this->reader->getPropertyAnnotations($property) as $rule) {

            //Skip is its not a rule
            if ( ! $rule instanceof Rules\Rule ) continue;
            
            //Add Rule
            $metadata->addPropertyRule($property->getName(), $rule);

        }

    }
474656
private function update(PropertyMetadata $propertyMetadata, array $metadata): PropertyMetadata
    {
        $metadataAccessors = [
            'description' => 'get',
            'readable' => 'is',
            'writable' => 'is',
            'writableLink' => 'is',
            'readableLink' => 'is',
            'required' => 'is',
            'identifier' => 'is',
            'iri' => 'get',
            'attributes' => 'get',
        ];

        foreach ($metadataAccessors as $metadataKey => $accessorPrefix) {
            if (null === $metadata[$metadataKey]) {
                continue;
            }

            $propertyMetadata = $propertyMetadata->{'with'.ucfirst($metadataKey)}($metadata[$metadataKey]);
        }

        if ($propertyMetadata->hasSubresource()) {
            return $propertyMetadata;
        }

        return $propertyMetadata->withSubresource($this->createSubresourceMetadata($metadata['subresource'], $propertyMetadata));
    }
1313258
protected function addChild(PropertyInterface $property)
    {
        if ($property instanceof SectionPropertyInterface) {
            foreach ($property->getChildProperties() as $childProperty) {
                $this->addPropertyTags($childProperty);
            }
        } else {
            $this->addPropertyTags($property);
        }

        $this->properties[$property->getName()] = $property;
    }
40805
public function preUpdate(ClassMetadata $class, $document)
    {
        if (!empty($class->lifecycleCallbacks[Event::preUpdate])) {
            $class->invokeLifecycleCallbacks(Event::preUpdate, $document, [
                new PreUpdateEventArgs($document, $this->dm, $this->uow->getDocumentChangeSet($document))
            ]);
            $this->uow->recomputeSingleDocumentChangeSet($class, $document);
        }
        $this->evm->dispatchEvent(Event::preUpdate, new PreUpdateEventArgs($document, $this->dm, $this->uow->getDocumentChangeSet($document)));
        $this->cascadePreUpdate($class, $document);
    }
536271
public function getTranslationData($entity, Property $property)
    {
        $metadata = $this->metadataCollection->getMetadata($entity);
        if($metadata === null) {
            return null;
        }

        $metaProperty = $metadata->getProperty($property->getName());

        if($metaProperty === null) {
            throw new TranslationException(
                sprintf('The property "%s" was used for translation, but no metadata was found. Maybe you forgot to define one for the entity "%s"',
                $property->getName(),
                get_class($entity)
            ));
        }

        $strategy = $this->strategyResolver->getStrategy($metaProperty->getStrategy());
        return $strategy->getTranslationData($entity, $metaProperty, $metadata);
    }
654698
public function prepareAssociatedDocumentValue(PropertyMetadata $mapping, $document, $includeNestedCollections = false)
    {
        if ($document === null) {
            return Type::getNull();
        }

        if ($mapping->embedded) {
            return $this->prepareEmbeddedDocumentValue($mapping, $document, $includeNestedCollections);
        }

        if ($mapping->reference) {
            $class      = $this->dm->getClassMetadata(get_class($document));
            $identifier = $class->createIdentifier($document);

            return $this->prepareReferencedDocumentValue($mapping, $identifier);
        }

        throw new \InvalidArgumentException('Mapping is neither embedded nor reference.');
    }
920876
public function shouldSkipProperty(PropertyMetadata $property)
    {
        if ((null !== $version = $property->getSinceVersion()) && version_compare($this->version, $version, '<')) {
            return true;
        }

        if ((null !== $version = $property->getUntilVersion()) && version_compare($this->version, $version, '>')) {
            return true;
        }

        return false;
    }
256679
public function postPersist(ClassMetadata $class, $document)
    {
        $class->invokeLifecycleCallbacks(Event::postPersist, $document, [new LifecycleEventArgs($document, $this->dm)]);
        $this->evm->dispatchEvent(Event::postPersist, new LifecycleEventArgs($document, $this->dm));
        $this->cascadePostPersist($class, $document);
    }
925494
protected function __setMeta($property, $value, $blnOverwrite = false)
    {
        $internalMetaArray = &$this->__meta;

        /**
         * Re-set internalMetaArray if property has magic key 'label', 'field', 'tip', 'dynamicLabel'
         * or 'dynamicRemoveLabel'
         */
        $strMagicKey = null;
        foreach ($this->__magicmeta as $strMagicMeta) {
            if (strpos(strtolower($property), strtolower($strMagicMeta)) === 0
                    && strlen($property) !== strlen($strMagicMeta)) {
                $strMagicKey = $strMagicMeta;

                break;
            }
        }

        if (!is_null($strMagicKey)) {
            switch ($strMagicKey) {
                case "field":
                    $internalMetaArray = &$this->__fieldmeta;
                    $property = strtolower(substr($property, - (strlen($property) - 5)));
                    break;
                case "label":
                    $internalMetaArray = &$this->__labelmeta;
                    $property = strtolower(substr($property, - (strlen($property) - 5)));
                    break;
                case "tip":
                    $internalMetaArray = &$this->__tipmeta;
                    $property = strtolower(substr($property, - (strlen($property) - 3)));
                    break;
                case "dynamicLabel":
                    $internalMetaArray = &$this->__dynamiclabelmeta;
                    $property = strtolower(substr($property, - (strlen($property) - 12)));
                    break;
                case "dynamicRemoveLabel":
                    $internalMetaArray = &$this->__dynamicremovelabelmeta;
                    $property = strtolower(substr($property, - (strlen($property) - 18)));
                    break;
                default:
            }
        }

        if ($blnOverwrite) {
            if (empty($value) || is_null($value)) {
                unset($internalMetaArray[$property]);
            } else {
                $internalMetaArray[$property] = $value;
            }

            return $value;
        } else {
            $varMeta = (isset($internalMetaArray[$property])) ? $internalMetaArray[$property] : "";

            // *** If the id is being set and there is already a value we don't set the new value.
            if ($property == "id" && $varMeta != "") {
                return $varMeta;
            }

            // *** Define delimiter per meta property.
            switch ($property) {
                case "style":
                    $strDelimiter = ";";
                    break;

                default:
                    $strDelimiter = " ";
            }

            // *** Add the value to the property string.
            $arrMeta = (! is_array($varMeta)) ? explode($strDelimiter, $varMeta) : $varMeta;
            $arrMeta[] = $value;

            // Make sure no empty values are left in the array.
            $arrMeta = array_filter($arrMeta);

            // Make sure there are no duplicate entries for the 'class' property
            if (strtolower($property) === 'class') {
                $arrMeta = array_unique($arrMeta);
            }

            $varMeta = implode($strDelimiter, $arrMeta);

            $internalMetaArray[$property] = $varMeta;

            return $varMeta;
        }
    }
1163126
protected function addToDocument($document)
    {
        parent::addToDocument($document);

        $this->getRangeKey()->getPropertyMetadata()->setValue(
            $document,
            $this->getRangeValue()
        );
    }
749088
public function setProperty($propertyName, $value)
    {
        if ($value !== $this->getProperty($propertyName)) {
            $this->setMeta(static::IS_CHANGED, true);
            $this->setPropertyRaw($propertyName, $value);
        }
    }
713308
public function setParentAssociation(object $document, array $mapping, ?object $parent, string $propertyPath) : void
    {
        $oid                                   = spl_object_hash($document);
        $this->embeddedDocumentsRegistry[$oid] = $document;
        $this->parentAssociations[$oid]        = [$mapping, $parent, $propertyPath];
    }
1243109
public function preUpdate(ClassMetadata $class, object $document) : void
    {
        if (! empty($class->lifecycleCallbacks[Events::preUpdate])) {
            $class->invokeLifecycleCallbacks(Events::preUpdate, $document, [new PreUpdateEventArgs($document, $this->dm, $this->uow->getDocumentChangeSet($document))]);
            $this->uow->recomputeSingleDocumentChangeSet($class, $document);
        }
        $this->evm->dispatchEvent(Events::preUpdate, new PreUpdateEventArgs($document, $this->dm, $this->uow->getDocumentChangeSet($document)));
        $this->cascadePreUpdate($class, $document);
    }
1043552
private function updateResourceSegmentProperty(
        NodeInterface $node,
        $resourceSegmentPropertyName,
        $parentUuid,
        $webspaceKey,
        $locale
    ) {
        $resourceLocatorStrategy = $this->resourceLocatorStrategyPool->getStrategyByWebspaceKey($webspaceKey);
        $childPart = $resourceLocatorStrategy->getChildPart($node->getPropertyValue($resourceSegmentPropertyName));

        $node->setProperty(
            $resourceSegmentPropertyName,
            $resourceLocatorStrategy->generate($childPart, $parentUuid, $webspaceKey, $locale)
        );
    }
476745
private function addStructureProperties(
        StructureMetadata $structureMetadata,
        StructureBehavior $document,
        VisitorInterface $visitor
    ) {
        /** @var ManagedStructure $structure */
        $structure = $document->getStructure();
        $data = $structure->toArray();
        foreach ($structureMetadata->getProperties() as $name => $property) {
            if ('title' === $name || !array_key_exists($name, $data) || $property->hasTag('sulu.rlp')) {
                continue;
            }

            $visitor->addData($name, $data[$name]);
        }
    }