private function listStory(Request $request, \record_adapter $story)
    {
        if (!$story->isStory()) {
            return Result::createError($request, 404, 'Story not found')->createResponse();
        }

        $caption = $story->get_caption();

        $format = function (\caption_record $caption, $dcField) {

            $field = $caption->get_dc_field($dcField);

            if (!$field) {
                return null;
            }

            return $field->get_serialized_values();
        };

        return [
            '@entity@'      => self::OBJECT_TYPE_STORY,
            'databox_id'    => $story->getDataboxId(),
            'story_id'      => $story->getRecordId(),
            'updated_on'    => $story->getUpdated()->format(DATE_ATOM),
            'created_on'    => $story->getCreated()->format(DATE_ATOM),
            'collection_id' => $story->getCollectionId(),
            'base_id'       => $story->getBaseId(),
            'thumbnail'     => $this->listEmbeddableMedia($request, $story, $story->get_thumbnail()),
            'uuid'          => $story->getUuid(),
            'metadatas'     => [
                '@entity@'       => self::OBJECT_TYPE_STORY_METADATA_BAG,
                'dc:contributor' => $format($caption, \databox_Field_DCESAbstract::Contributor),
                'dc:coverage'    => $format($caption, \databox_Field_DCESAbstract::Coverage),
                'dc:creator'     => $format($caption, \databox_Field_DCESAbstract::Creator),
                'dc:date'        => $format($caption, \databox_Field_DCESAbstract::Date),
                'dc:description' => $format($caption, \databox_Field_DCESAbstract::Description),
                'dc:format'      => $format($caption, \databox_Field_DCESAbstract::Format),
                'dc:identifier'  => $format($caption, \databox_Field_DCESAbstract::Identifier),
                'dc:language'    => $format($caption, \databox_Field_DCESAbstract::Language),
                'dc:publisher'   => $format($caption, \databox_Field_DCESAbstract::Publisher),
                'dc:relation'    => $format($caption, \databox_Field_DCESAbstract::Relation),
                'dc:rights'      => $format($caption, \databox_Field_DCESAbstract::Rights),
                'dc:source'      => $format($caption, \databox_Field_DCESAbstract::Source),
                'dc:subject'     => $format($caption, \databox_Field_DCESAbstract::Subject),
                'dc:title'       => $format($caption, \databox_Field_DCESAbstract::Title),
                'dc:type'        => $format($caption, \databox_Field_DCESAbstract::Type),
            ],
            'records'       => $this->listRecords($request, array_values($story->getChildren()->get_elements())),
        ];
    }
private function listStory(Request $request, \record_adapter $story)
    {
        if (!$story->isStory()) {
            return Result::createError($request, 404, 'Story not found')->createResponse();
        }

        $caption = $story->get_caption();

        $format = function (\caption_record $caption, $dcField) {

            $field = $caption->get_dc_field($dcField);

            if (!$field) {
                return null;
            }

            return $field->get_serialized_values();
        };

        return [
            '@entity@'      => self::OBJECT_TYPE_STORY,
            'databox_id'    => $story->getDataboxId(),
            'story_id'      => $story->getRecordId(),
            'updated_on'    => $story->getUpdated()->format(DATE_ATOM),
            'created_on'    => $story->getCreated()->format(DATE_ATOM),
            'collection_id' => $story->getCollectionId(),
            'base_id'       => $story->getBaseId(),
            'thumbnail'     => $this->listEmbeddableMedia($request, $story, $story->get_thumbnail()),
            'uuid'          => $story->getUuid(),
            'metadatas'     => [
                '@entity@'       => self::OBJECT_TYPE_STORY_METADATA_BAG,
                'dc:contributor' => $format($caption, \databox_Field_DCESAbstract::Contributor),
                'dc:coverage'    => $format($caption, \databox_Field_DCESAbstract::Coverage),
                'dc:creator'     => $format($caption, \databox_Field_DCESAbstract::Creator),
                'dc:date'        => $format($caption, \databox_Field_DCESAbstract::Date),
                'dc:description' => $format($caption, \databox_Field_DCESAbstract::Description),
                'dc:format'      => $format($caption, \databox_Field_DCESAbstract::Format),
                'dc:identifier'  => $format($caption, \databox_Field_DCESAbstract::Identifier),
                'dc:language'    => $format($caption, \databox_Field_DCESAbstract::Language),
                'dc:publisher'   => $format($caption, \databox_Field_DCESAbstract::Publisher),
                'dc:relation'    => $format($caption, \databox_Field_DCESAbstract::Relation),
                'dc:rights'      => $format($caption, \databox_Field_DCESAbstract::Rights),
                'dc:source'      => $format($caption, \databox_Field_DCESAbstract::Source),
                'dc:subject'     => $format($caption, \databox_Field_DCESAbstract::Subject),
                'dc:title'       => $format($caption, \databox_Field_DCESAbstract::Title),
                'dc:type'        => $format($caption, \databox_Field_DCESAbstract::Type),
            ],
            'records'       => $this->listRecords($request, array_values($story->getChildren()->get_elements())),
        ];
    }
private function listStory ( Request $ request , \ record_adapter $ story ) { if ( ! $ story -> isStory ( ) ) { return Result :: createError ( $ request , 404 , 'Story not found' ) -> createResponse ( ) ; } $ caption = $ story -> get_caption ( ) ; $ format = function ( \ caption_record $ caption , $ dcField ) { $ field = $ caption -> get_dc_field ( $ dcField ) ; if ( ! $ field ) { return null ; } return $ field -> get_serialized_values ( ) ; } ; return [ '@entity@' => self :: OBJECT_TYPE_STORY , 'databox_id' => $ story -> getDataboxId ( ) , 'story_id' => $ story -> getRecordId ( ) , 'updated_on' => $ story -> getUpdated ( ) -> format ( DATE_ATOM ) , 'created_on' => $ story -> getCreated ( ) -> format ( DATE_ATOM ) , 'collection_id' => $ story -> getCollectionId ( ) , 'base_id' => $ story -> getBaseId ( ) , 'thumbnail' => $ this -> listEmbeddableMedia ( $ request , $ story , $ story -> get_thumbnail ( ) ) , 'uuid' => $ story -> getUuid ( ) , 'metadatas' => [ '@entity@' => self :: OBJECT_TYPE_STORY_METADATA_BAG , 'dc:contributor' => $ format ( $ caption , \ databox_Field_DCESAbstract :: Contributor ) , 'dc:coverage' => $ format ( $ caption , \ databox_Field_DCESAbstract :: Coverage ) , 'dc:creator' => $ format ( $ caption , \ databox_Field_DCESAbstract :: Creator ) , 'dc:date' => $ format ( $ caption , \ databox_Field_DCESAbstract :: Date ) , 'dc:description' => $ format ( $ caption , \ databox_Field_DCESAbstract :: Description ) , 'dc:format' => $ format ( $ caption , \ databox_Field_DCESAbstract :: Format ) , 'dc:identifier' => $ format ( $ caption , \ databox_Field_DCESAbstract :: Identifier ) , 'dc:language' => $ format ( $ caption , \ databox_Field_DCESAbstract :: Language ) , 'dc:publisher' => $ format ( $ caption , \ databox_Field_DCESAbstract :: Publisher ) , 'dc:relation' => $ format ( $ caption , \ databox_Field_DCESAbstract :: Relation ) , 'dc:rights' => $ format ( $ caption , \ databox_Field_DCESAbstract :: Rights ) , 'dc:source' => $ format ( $ caption , \ databox_Field_DCESAbstract :: Source ) , 'dc:subject' => $ format ( $ caption , \ databox_Field_DCESAbstract :: Subject ) , 'dc:title' => $ format ( $ caption , \ databox_Field_DCESAbstract :: Title ) , 'dc:type' => $ format ( $ caption , \ databox_Field_DCESAbstract :: Type ) , ] , 'records' => $ this -> listRecords ( $ request , array_values ( $ story -> getChildren ( ) -> get_elements ( ) ) ) , ] ; }
Retrieve detailed information about one story

@param Request         $request
@param \record_adapter $story
@return array
@throws \Exception
Retrieve detailed information about one story