Rest/Content/Content.php
public function prepareContent($data, ParameterBag $options, OutputInterface $output = null)
    {
        if ($output === null) {
            $output = new NullOutput();
        }

        $content = array();

        foreach ($data as $contentTypeId => $items) {
            $progress = new ProgressBar($output, count($items));
            $progress->start();

            foreach ($items as $contentValue) {
                $contentValue = $contentValue->valueObject;
                $contentType = $this->contentTypeService->loadContentType($contentValue->contentInfo->contentTypeId);
                $location = $this->locationService->loadLocation($contentValue->contentInfo->mainLocationId);
                $language = $options->get('lang', $location->contentInfo->mainLanguageCode);
                $this->value->setFieldDefinitionsList($contentType);

                $content[$contentTypeId][$contentValue->id] = array(
                    'contentId' => $contentValue->id,
                    'contentTypeId' => $contentType->id,
                    'identifier' => $contentType->identifier,
                    'language' => $language,
                    'publishedDate' => $contentValue->contentInfo->publishedDate->format('c'),
                    'author' => $this->getAuthor($contentValue, $contentType),
                    'uri' => $this->generator->generate($location, array(), false),
                    'mainLocation' => array(
                        'href' => '/api/ezp/v2/content/locations' . $location->pathString,
                    ),
                    'locations' => array(
                        'href' => '/api/ezp/v2/content/objects/' . $contentValue->id . '/locations',
                    ),
                    'categoryPath' => $location->pathString,
                    'fields' => array(),
                );

                $fields = $this->prepareFields($contentType, $options->get('fields'));
                if (!empty($fields)) {
                    foreach ($fields as $field) {
                        $field = $this->value->getConfiguredFieldIdentifier($field, $contentType);
                        $content[$contentTypeId][$contentValue->id]['fields'][$field] =
                            $this->value->getFieldValue($contentValue, $field, $language, $options->all());
                    }
                }

                $progress->advance();
            }

            $progress->finish();
            $output->writeln('');
        }

        return $content;
    }
public function prepareContent($data, ParameterBag $options, OutputInterface $output = null)
    {
        if ($output === null) {
            $output = new NullOutput();
        }

        $content = array();

        foreach ($data as $contentTypeId => $items) {
            $progress = new ProgressBar($output, count($items));
            $progress->start();

            foreach ($items as $contentValue) {
                $contentValue = $contentValue->valueObject;
                $contentType = $this->contentTypeService->loadContentType($contentValue->contentInfo->contentTypeId);
                $location = $this->locationService->loadLocation($contentValue->contentInfo->mainLocationId);
                $language = $options->get('lang', $location->contentInfo->mainLanguageCode);
                $this->value->setFieldDefinitionsList($contentType);

                $content[$contentTypeId][$contentValue->id] = array(
                    'contentId' => $contentValue->id,
                    'contentTypeId' => $contentType->id,
                    'identifier' => $contentType->identifier,
                    'language' => $language,
                    'publishedDate' => $contentValue->contentInfo->publishedDate->format('c'),
                    'author' => $this->getAuthor($contentValue, $contentType),
                    'uri' => $this->generator->generate($location, array(), false),
                    'mainLocation' => array(
                        'href' => '/api/ezp/v2/content/locations' . $location->pathString,
                    ),
                    'locations' => array(
                        'href' => '/api/ezp/v2/content/objects/' . $contentValue->id . '/locations',
                    ),
                    'categoryPath' => $location->pathString,
                    'fields' => array(),
                );

                $fields = $this->prepareFields($contentType, $options->get('fields'));
                if (!empty($fields)) {
                    foreach ($fields as $field) {
                        $field = $this->value->getConfiguredFieldIdentifier($field, $contentType);
                        $content[$contentTypeId][$contentValue->id]['fields'][$field] =
                            $this->value->getFieldValue($contentValue, $field, $language, $options->all());
                    }
                }

                $progress->advance();
            }

            $progress->finish();
            $output->writeln('');
        }

        return $content;
    }
public function prepareContent ( $ data , ParameterBag $ options , OutputInterface $ output = null ) { if ( $ output === null ) { $ output = new NullOutput ( ) ; } $ content = array ( ) ; foreach ( $ data as $ contentTypeId => $ items ) { $ progress = new ProgressBar ( $ output , count ( $ items ) ) ; $ progress -> start ( ) ; foreach ( $ items as $ contentValue ) { $ contentValue = $ contentValue -> valueObject ; $ contentType = $ this -> contentTypeService -> loadContentType ( $ contentValue -> contentInfo -> contentTypeId ) ; $ location = $ this -> locationService -> loadLocation ( $ contentValue -> contentInfo -> mainLocationId ) ; $ language = $ options -> get ( 'lang' , $ location -> contentInfo -> mainLanguageCode ) ; $ this -> value -> setFieldDefinitionsList ( $ contentType ) ; $ content [ $ contentTypeId ] [ $ contentValue -> id ] = array ( 'contentId' => $ contentValue -> id , 'contentTypeId' => $ contentType -> id , 'identifier' => $ contentType -> identifier , 'language' => $ language , 'publishedDate' => $ contentValue -> contentInfo -> publishedDate -> format ( 'c' ) , 'author' => $ this -> getAuthor ( $ contentValue , $ contentType ) , 'uri' => $ this -> generator -> generate ( $ location , array ( ) , false ) , 'mainLocation' => array ( 'href' => '/api/ezp/v2/content/locations' . $ location -> pathString , ) , 'locations' => array ( 'href' => '/api/ezp/v2/content/objects/' . $ contentValue -> id . '/locations' , ) , 'categoryPath' => $ location -> pathString , 'fields' => array ( ) , ) ; $ fields = $ this -> prepareFields ( $ contentType , $ options -> get ( 'fields' ) ) ; if ( ! empty ( $ fields ) ) { foreach ( $ fields as $ field ) { $ field = $ this -> value -> getConfiguredFieldIdentifier ( $ field , $ contentType ) ; $ content [ $ contentTypeId ] [ $ contentValue -> id ] [ 'fields' ] [ $ field ] = $ this -> value -> getFieldValue ( $ contentValue , $ field , $ language , $ options -> all ( ) ) ; } } $ progress -> advance ( ) ; } $ progress -> finish ( ) ; $ output -> writeln ( '' ) ; } return $ content ; }
Prepare content array.

@param array $data
@param ParameterBag $options
@param OutputInterface|null $output

@return array
Prepare content array .