public function supply(ContentView $view)
    {
        /** @var \eZ\Publish\API\Repository\Values\ContentType\ContentType[] $contentTypes */
        $contentTypes = [];
        $subitemsRows = [];
        $location = $view->getLocation();
        $childrenCount = $this->locationService->getLocationChildCount($location);

        $subitemsLimit = (int)$this->userSettingService->getUserSetting('subitems_limit')->value;

        $locationChildren = $this->locationService->loadLocationChildren($location, 0, $subitemsLimit);
        foreach ($locationChildren->locations as $locationChild) {
            $contentType = $locationChild->getContent()->getContentType();

            if (!isset($contentTypes[$contentType->identifier])) {
                $contentTypes[$contentType->identifier] = $contentType;
            }

            $subitemsRows[] = $this->createSubitemsRow($locationChild, $contentType);
        }

        $subitemsList = new SubitemsList($subitemsRows, $childrenCount);
        $contentTypeInfoList = new ContentTypeInfoList($contentTypes, '');

        $subitemsListJson = $this->visitSubitemsList($subitemsList);
        $contentTypeInfoListJson = $this->visitContentTypeInfoList($contentTypeInfoList);

        $view->addParameters([
            'subitems_module' => [
                'items' => $subitemsListJson,
                /* @deprecated since version 2.2, to be removed in 3.0 */
                'limit' => $subitemsLimit,
                'content_type_info_list' => $contentTypeInfoListJson,
                'content_create_permissions_for_mfu' => $this->getContentCreatePermissionsForMFU($view->getLocation(), $view->getContent()),
            ],
        ]);
    }
public function supply(ContentView $view)
    {
        /** @var \eZ\Publish\API\Repository\Values\ContentType\ContentType[] $contentTypes */
        $contentTypes = [];
        $subitemsRows = [];
        $location = $view->getLocation();
        $childrenCount = $this->locationService->getLocationChildCount($location);

        $subitemsLimit = (int)$this->userSettingService->getUserSetting('subitems_limit')->value;

        $locationChildren = $this->locationService->loadLocationChildren($location, 0, $subitemsLimit);
        foreach ($locationChildren->locations as $locationChild) {
            $contentType = $locationChild->getContent()->getContentType();

            if (!isset($contentTypes[$contentType->identifier])) {
                $contentTypes[$contentType->identifier] = $contentType;
            }

            $subitemsRows[] = $this->createSubitemsRow($locationChild, $contentType);
        }

        $subitemsList = new SubitemsList($subitemsRows, $childrenCount);
        $contentTypeInfoList = new ContentTypeInfoList($contentTypes, '');

        $subitemsListJson = $this->visitSubitemsList($subitemsList);
        $contentTypeInfoListJson = $this->visitContentTypeInfoList($contentTypeInfoList);

        $view->addParameters([
            'subitems_module' => [
                'items' => $subitemsListJson,
                /* @deprecated since version 2.2, to be removed in 3.0 */
                'limit' => $subitemsLimit,
                'content_type_info_list' => $contentTypeInfoListJson,
                'content_create_permissions_for_mfu' => $this->getContentCreatePermissionsForMFU($view->getLocation(), $view->getContent()),
            ],
        ]);
    }
public function supply ( ContentView $ view ) { /** @var \eZ\Publish\API\Repository\Values\ContentType\ContentType[] $contentTypes */ $ contentTypes = [ ] ; $ subitemsRows = [ ] ; $ location = $ view -> getLocation ( ) ; $ childrenCount = $ this -> locationService -> getLocationChildCount ( $ location ) ; $ subitemsLimit = ( int ) $ this -> userSettingService -> getUserSetting ( 'subitems_limit' ) -> value ; $ locationChildren = $ this -> locationService -> loadLocationChildren ( $ location , 0 , $ subitemsLimit ) ; foreach ( $ locationChildren -> locations as $ locationChild ) { $ contentType = $ locationChild -> getContent ( ) -> getContentType ( ) ; if ( ! isset ( $ contentTypes [ $ contentType -> identifier ] ) ) { $ contentTypes [ $ contentType -> identifier ] = $ contentType ; } $ subitemsRows [ ] = $ this -> createSubitemsRow ( $ locationChild , $ contentType ) ; } $ subitemsList = new SubitemsList ( $ subitemsRows , $ childrenCount ) ; $ contentTypeInfoList = new ContentTypeInfoList ( $ contentTypes , '' ) ; $ subitemsListJson = $ this -> visitSubitemsList ( $ subitemsList ) ; $ contentTypeInfoListJson = $ this -> visitContentTypeInfoList ( $ contentTypeInfoList ) ; $ view -> addParameters ( [ 'subitems_module' => [ 'items' => $ subitemsListJson , /* @deprecated since version 2.2, to be removed in 3.0 */ 'limit' => $ subitemsLimit , 'content_type_info_list' => $ contentTypeInfoListJson , 'content_create_permissions_for_mfu' => $ this -> getContentCreatePermissionsForMFU ( $ view -> getLocation ( ) , $ view -> getContent ( ) ) , ] , ] ) ; }
Fetches data for Subitems module to populate it with preloaded data.

Why are we using REST stuff here?

This is not so elegant but to preload data in Subitems module
we are using the same data structure it would use while
fetching data from the REST.

@param \eZ\Publish\Core\MVC\Symfony\View\ContentView $view

@throws \eZ\Publish\API\Repository\Exceptions\BadStateException
@throws \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException
@throws \eZ\Publish\API\Repository\Exceptions\NotFoundException
@throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException
Fetches data for Subitems module to populate it with preloaded data .