src/Sulu/Component/DocumentManager/Subscriber/Behavior/VersionSubscriber.php
public function applyVersionOperations()
    {
        foreach ($this->checkoutUuids as $uuid) {
            $node = $this->defaultSession->getNodeByIdentifier($uuid);
            $path = $node->getPath();

            if (!$this->versionManager->isCheckedOut($path)) {
                $this->versionManager->checkout($path);
            }
        }

        $this->checkoutUuids = [];

        /** @var NodeInterface[] $nodes */
        $nodes = [];
        $nodeVersions = [];
        foreach ($this->checkpointUuids as $versionInformation) {
            $node = $this->defaultSession->getNodeByIdentifier($versionInformation['uuid']);
            $path = $node->getPath();

            $version = $this->versionManager->checkpoint($path);

            if (!array_key_exists($path, $nodes)) {
                $nodes[$path] = $this->defaultSession->getNode($path);
            }
            $versions = $nodes[$path]->getPropertyValueWithDefault(static::VERSION_PROPERTY, []);

            if (!array_key_exists($path, $nodeVersions)) {
                $nodeVersions[$path] = $versions;
            }
            $nodeVersions[$path][] = json_encode(
                [
                    'locale' => $versionInformation['locale'],
                    'version' => $version->getName(),
                    'author' => $versionInformation['author'],
                    'authored' => date('c'),
                ]
            );
        }

        foreach ($nodes as $uuid => $node) {
            $node->setProperty(static::VERSION_PROPERTY, $nodeVersions[$uuid]);
        }

        $this->defaultSession->save();
        $this->checkpointUuids = [];
    }
public function applyVersionOperations()
    {
        foreach ($this->checkoutUuids as $uuid) {
            $node = $this->defaultSession->getNodeByIdentifier($uuid);
            $path = $node->getPath();

            if (!$this->versionManager->isCheckedOut($path)) {
                $this->versionManager->checkout($path);
            }
        }

        $this->checkoutUuids = [];

        /** @var NodeInterface[] $nodes */
        $nodes = [];
        $nodeVersions = [];
        foreach ($this->checkpointUuids as $versionInformation) {
            $node = $this->defaultSession->getNodeByIdentifier($versionInformation['uuid']);
            $path = $node->getPath();

            $version = $this->versionManager->checkpoint($path);

            if (!array_key_exists($path, $nodes)) {
                $nodes[$path] = $this->defaultSession->getNode($path);
            }
            $versions = $nodes[$path]->getPropertyValueWithDefault(static::VERSION_PROPERTY, []);

            if (!array_key_exists($path, $nodeVersions)) {
                $nodeVersions[$path] = $versions;
            }
            $nodeVersions[$path][] = json_encode(
                [
                    'locale' => $versionInformation['locale'],
                    'version' => $version->getName(),
                    'author' => $versionInformation['author'],
                    'authored' => date('c'),
                ]
            );
        }

        foreach ($nodes as $uuid => $node) {
            $node->setProperty(static::VERSION_PROPERTY, $nodeVersions[$uuid]);
        }

        $this->defaultSession->save();
        $this->checkpointUuids = [];
    }
public function applyVersionOperations ( ) { foreach ( $ this -> checkoutUuids as $ uuid ) { $ node = $ this -> defaultSession -> getNodeByIdentifier ( $ uuid ) ; $ path = $ node -> getPath ( ) ; if ( ! $ this -> versionManager -> isCheckedOut ( $ path ) ) { $ this -> versionManager -> checkout ( $ path ) ; } } $ this -> checkoutUuids = [ ] ; /** @var NodeInterface[] $nodes */ $ nodes = [ ] ; $ nodeVersions = [ ] ; foreach ( $ this -> checkpointUuids as $ versionInformation ) { $ node = $ this -> defaultSession -> getNodeByIdentifier ( $ versionInformation [ 'uuid' ] ) ; $ path = $ node -> getPath ( ) ; $ version = $ this -> versionManager -> checkpoint ( $ path ) ; if ( ! array_key_exists ( $ path , $ nodes ) ) { $ nodes [ $ path ] = $ this -> defaultSession -> getNode ( $ path ) ; } $ versions = $ nodes [ $ path ] -> getPropertyValueWithDefault ( static :: VERSION_PROPERTY , [ ] ) ; if ( ! array_key_exists ( $ path , $ nodeVersions ) ) { $ nodeVersions [ $ path ] = $ versions ; } $ nodeVersions [ $ path ] [ ] = json_encode ( [ 'locale' => $ versionInformation [ 'locale' ] , 'version' => $ version -> getName ( ) , 'author' => $ versionInformation [ 'author' ] , 'authored' => date ( 'c' ) , ] ) ; } foreach ( $ nodes as $ uuid => $ node ) { $ node -> setProperty ( static :: VERSION_PROPERTY , $ nodeVersions [ $ uuid ] ) ; } $ this -> defaultSession -> save ( ) ; $ this -> checkpointUuids = [ ] ; }
Apply all the operations which have been remembered after the flush.
Apply all the operations which have been remembered after the flush .