src/Sulu/Bundle/PageBundle/Controller/VersionController.php
public function cgetAction(Request $request, $uuid)
    {
        $locale = $this->getRequestParameter($request, 'language', true);

        $document = $this->get('sulu_document_manager.document_manager')->find($uuid, $request->query->get('language'));
        $versions = array_reverse(array_filter($document->getVersions(), function($version) use ($locale) {
            /* @var Version $version */
            return $version->getLocale() === $locale;
        }));
        $total = count($versions);

        $listRestHelper = $this->get('sulu_core.list_rest_helper');
        $limit = $listRestHelper->getLimit();

        $versions = array_slice($versions, $listRestHelper->getOffset(), $limit);

        $userIds = array_unique(array_map(function($version) {
            /* @var Version $version */
            return $version->getAuthor();
        }, $versions));

        $users = $this->get('sulu_security.user_repository')->findUsersById($userIds);
        $fullNamesByIds = [];
        foreach ($users as $user) {
            $fullNamesByIds[$user->getId()] = $user->getContact()->getFullName();
        }

        $versionData = [];
        foreach ($versions as $version) {
            $versionData[] = [
                'id' => str_replace('.', '_', $version->getId()),
                'locale' => $version->getLocale(),
                'author' => array_key_exists($version->getAuthor(), $fullNamesByIds)
                    ? $fullNamesByIds[$version->getAuthor()] : '',
                'authored' => $version->getAuthored(),
            ];
        }

        $versionCollection = new ListRepresentation(
            $versionData,
            'versions',
            'get_node_versions',
            [
                'uuid' => $uuid,
                'language' => $locale,
                'webspace' => $request->get('webspace'),
            ],
            $listRestHelper->getPage(),
            $limit,
            $total
        );

        return $this->handleView($this->view($versionCollection));
    }
public function cgetAction(Request $request, $uuid)
    {
        $locale = $this->getRequestParameter($request, 'language', true);

        $document = $this->get('sulu_document_manager.document_manager')->find($uuid, $request->query->get('language'));
        $versions = array_reverse(array_filter($document->getVersions(), function($version) use ($locale) {
            /* @var Version $version */
            return $version->getLocale() === $locale;
        }));
        $total = count($versions);

        $listRestHelper = $this->get('sulu_core.list_rest_helper');
        $limit = $listRestHelper->getLimit();

        $versions = array_slice($versions, $listRestHelper->getOffset(), $limit);

        $userIds = array_unique(array_map(function($version) {
            /* @var Version $version */
            return $version->getAuthor();
        }, $versions));

        $users = $this->get('sulu_security.user_repository')->findUsersById($userIds);
        $fullNamesByIds = [];
        foreach ($users as $user) {
            $fullNamesByIds[$user->getId()] = $user->getContact()->getFullName();
        }

        $versionData = [];
        foreach ($versions as $version) {
            $versionData[] = [
                'id' => str_replace('.', '_', $version->getId()),
                'locale' => $version->getLocale(),
                'author' => array_key_exists($version->getAuthor(), $fullNamesByIds)
                    ? $fullNamesByIds[$version->getAuthor()] : '',
                'authored' => $version->getAuthored(),
            ];
        }

        $versionCollection = new ListRepresentation(
            $versionData,
            'versions',
            'get_node_versions',
            [
                'uuid' => $uuid,
                'language' => $locale,
                'webspace' => $request->get('webspace'),
            ],
            $listRestHelper->getPage(),
            $limit,
            $total
        );

        return $this->handleView($this->view($versionCollection));
    }
public function cgetAction ( Request $ request , $ uuid ) { $ locale = $ this -> getRequestParameter ( $ request , 'language' , true ) ; $ document = $ this -> get ( 'sulu_document_manager.document_manager' ) -> find ( $ uuid , $ request -> query -> get ( 'language' ) ) ; $ versions = array_reverse ( array_filter ( $ document -> getVersions ( ) , function ( $ version ) use ( $ locale ) { /* @var Version $version */ return $ version -> getLocale ( ) === $ locale ; } ) ) ; $ total = count ( $ versions ) ; $ listRestHelper = $ this -> get ( 'sulu_core.list_rest_helper' ) ; $ limit = $ listRestHelper -> getLimit ( ) ; $ versions = array_slice ( $ versions , $ listRestHelper -> getOffset ( ) , $ limit ) ; $ userIds = array_unique ( array_map ( function ( $ version ) { /* @var Version $version */ return $ version -> getAuthor ( ) ; } , $ versions ) ) ; $ users = $ this -> get ( 'sulu_security.user_repository' ) -> findUsersById ( $ userIds ) ; $ fullNamesByIds = [ ] ; foreach ( $ users as $ user ) { $ fullNamesByIds [ $ user -> getId ( ) ] = $ user -> getContact ( ) -> getFullName ( ) ; } $ versionData = [ ] ; foreach ( $ versions as $ version ) { $ versionData [ ] = [ 'id' => str_replace ( '.' , '_' , $ version -> getId ( ) ) , 'locale' => $ version -> getLocale ( ) , 'author' => array_key_exists ( $ version -> getAuthor ( ) , $ fullNamesByIds ) ? $ fullNamesByIds [ $ version -> getAuthor ( ) ] : '' , 'authored' => $ version -> getAuthored ( ) , ] ; } $ versionCollection = new ListRepresentation ( $ versionData , 'versions' , 'get_node_versions' , [ 'uuid' => $ uuid , 'language' => $ locale , 'webspace' => $ request -> get ( 'webspace' ) , ] , $ listRestHelper -> getPage ( ) , $ limit , $ total ) ; return $ this -> handleView ( $ this -> view ( $ versionCollection ) ) ; }
Returns the versions for the node with the given UUID.

@param Request $request
@param string $uuid

@return Response
Returns the versions for the node with the given UUID .