private function setMixins(Mapping\ClassMetadata $metadata, NodeInterface $node, $document)
    {
        $repository = $this->session->getRepository();
        if ($metadata->versionable === 'full') {
            if ($repository->getDescriptor(RepositoryInterface::OPTION_VERSIONING_SUPPORTED)) {
                $node->addMixin('mix:versionable');
            } elseif ($repository->getDescriptor(RepositoryInterface::OPTION_SIMPLE_VERSIONING_SUPPORTED)) {
                $node->addMixin('mix:simpleVersionable');
            }
        } elseif ($metadata->versionable === 'simple'
            && $repository->getDescriptor(RepositoryInterface::OPTION_SIMPLE_VERSIONING_SUPPORTED)
        ) {
            $node->addMixin('mix:simpleVersionable');
        }

        if (!$node->isNodeType('mix:referenceable') && $metadata->referenceable) {
            $node->addMixin('mix:referenceable');
        }

        // manually set the uuid if it is not present yet, so we can assign it to documents
        if ($node->isNodeType('mix:referenceable') && !$node->hasProperty('jcr:uuid')) {
            $uuid = false;

            $uuidFieldName = $metadata->getUuidFieldName();
            if ($uuidFieldName) {
                $uuid = $metadata->getFieldValue($document, $uuidFieldName);
            }

            if (!$uuid) {
                $uuid = $this->generateUuid();
            }

            $node->setProperty('jcr:uuid', $uuid);

            if ($uuidFieldName && !$metadata->getFieldValue($document, $uuidFieldName)) {
                $metadata->setFieldValue($document, $uuidFieldName, $uuid);
            }
        }
    }
private function setMixins(Mapping\ClassMetadata $metadata, NodeInterface $node, $document)
    {
        $repository = $this->session->getRepository();
        if ($metadata->versionable === 'full') {
            if ($repository->getDescriptor(RepositoryInterface::OPTION_VERSIONING_SUPPORTED)) {
                $node->addMixin('mix:versionable');
            } elseif ($repository->getDescriptor(RepositoryInterface::OPTION_SIMPLE_VERSIONING_SUPPORTED)) {
                $node->addMixin('mix:simpleVersionable');
            }
        } elseif ($metadata->versionable === 'simple'
            && $repository->getDescriptor(RepositoryInterface::OPTION_SIMPLE_VERSIONING_SUPPORTED)
        ) {
            $node->addMixin('mix:simpleVersionable');
        }

        if (!$node->isNodeType('mix:referenceable') && $metadata->referenceable) {
            $node->addMixin('mix:referenceable');
        }

        // manually set the uuid if it is not present yet, so we can assign it to documents
        if ($node->isNodeType('mix:referenceable') && !$node->hasProperty('jcr:uuid')) {
            $uuid = false;

            $uuidFieldName = $metadata->getUuidFieldName();
            if ($uuidFieldName) {
                $uuid = $metadata->getFieldValue($document, $uuidFieldName);
            }

            if (!$uuid) {
                $uuid = $this->generateUuid();
            }

            $node->setProperty('jcr:uuid', $uuid);

            if ($uuidFieldName && !$metadata->getFieldValue($document, $uuidFieldName)) {
                $metadata->setFieldValue($document, $uuidFieldName, $uuid);
            }
        }
    }
private function setMixins ( Mapping \ ClassMetadata $ metadata , NodeInterface $ node , $ document ) { $ repository = $ this -> session -> getRepository ( ) ; if ( $ metadata -> versionable === 'full' ) { if ( $ repository -> getDescriptor ( RepositoryInterface :: OPTION_VERSIONING_SUPPORTED ) ) { $ node -> addMixin ( 'mix:versionable' ) ; } elseif ( $ repository -> getDescriptor ( RepositoryInterface :: OPTION_SIMPLE_VERSIONING_SUPPORTED ) ) { $ node -> addMixin ( 'mix:simpleVersionable' ) ; } } elseif ( $ metadata -> versionable === 'simple' && $ repository -> getDescriptor ( RepositoryInterface :: OPTION_SIMPLE_VERSIONING_SUPPORTED ) ) { $ node -> addMixin ( 'mix:simpleVersionable' ) ; } if ( ! $ node -> isNodeType ( 'mix:referenceable' ) && $ metadata -> referenceable ) { $ node -> addMixin ( 'mix:referenceable' ) ; } // manually set the uuid if it is not present yet, so we can assign it to documents if ( $ node -> isNodeType ( 'mix:referenceable' ) && ! $ node -> hasProperty ( 'jcr:uuid' ) ) { $ uuid = false ; $ uuidFieldName = $ metadata -> getUuidFieldName ( ) ; if ( $ uuidFieldName ) { $ uuid = $ metadata -> getFieldValue ( $ document , $ uuidFieldName ) ; } if ( ! $ uuid ) { $ uuid = $ this -> generateUuid ( ) ; } $ node -> setProperty ( 'jcr:uuid' , $ uuid ) ; if ( $ uuidFieldName && ! $ metadata -> getFieldValue ( $ document , $ uuidFieldName ) ) { $ metadata -> setFieldValue ( $ document , $ uuidFieldName , $ uuid ) ; } } }
Set the mapped mixins.

@param ClassMetadata $metadata
@param NodeInterface $node
@param object        $document The document to update autogenerated fields.
Set the mapped mixins .