src/ResultEncoder/ResultEncoder.php
private function encodeCollection(CollectionInterface $action_result, ResponseInterface $response)
    {
        $response = $response->write(json_encode($action_result))->withStatus(200);

        if ($action_result->canBeEtagged()) {
            if ($action_result->getApplicationIdentifier() != $this->app_identifier) {
                $action_result->setApplicationIdentifier($this->app_identifier); // Sign collection etag with app identifier
            }

            $response = $this->cache_provider->withEtag($response, $action_result->getEtag($this->user_identifier));
            $response = $this->cache_provider->withExpires($response, '+90 days');
        }

        if ($action_result->getCurrentPage() && $action_result->getItemsPerPage()) {
            $response = $response->withHeader('X-PaginationCurrentPage', $action_result->getCurrentPage())
                ->withHeader('X-PaginationItemsPerPage', $action_result->getItemsPerPage())
                ->withHeader('X-PaginationTotalItems', $action_result->count());
        } else {
            $response = $response->withHeader('X-PaginationCurrentPage', 0)
                ->withHeader('X-PaginationItemsPerPage', 0)
                ->withHeader('X-PaginationTotalItems', $action_result->count());
        }

        return $response;
    }
private function encodeCollection(CollectionInterface $action_result, ResponseInterface $response)
    {
        $response = $response->write(json_encode($action_result))->withStatus(200);

        if ($action_result->canBeEtagged()) {
            if ($action_result->getApplicationIdentifier() != $this->app_identifier) {
                $action_result->setApplicationIdentifier($this->app_identifier); // Sign collection etag with app identifier
            }

            $response = $this->cache_provider->withEtag($response, $action_result->getEtag($this->user_identifier));
            $response = $this->cache_provider->withExpires($response, '+90 days');
        }

        if ($action_result->getCurrentPage() && $action_result->getItemsPerPage()) {
            $response = $response->withHeader('X-PaginationCurrentPage', $action_result->getCurrentPage())
                ->withHeader('X-PaginationItemsPerPage', $action_result->getItemsPerPage())
                ->withHeader('X-PaginationTotalItems', $action_result->count());
        } else {
            $response = $response->withHeader('X-PaginationCurrentPage', 0)
                ->withHeader('X-PaginationItemsPerPage', 0)
                ->withHeader('X-PaginationTotalItems', $action_result->count());
        }

        return $response;
    }
private function encodeCollection ( CollectionInterface $ action_result , ResponseInterface $ response ) { $ response = $ response -> write ( json_encode ( $ action_result ) ) -> withStatus ( 200 ) ; if ( $ action_result -> canBeEtagged ( ) ) { if ( $ action_result -> getApplicationIdentifier ( ) != $ this -> app_identifier ) { $ action_result -> setApplicationIdentifier ( $ this -> app_identifier ) ; // Sign collection etag with app identifier } $ response = $ this -> cache_provider -> withEtag ( $ response , $ action_result -> getEtag ( $ this -> user_identifier ) ) ; $ response = $ this -> cache_provider -> withExpires ( $ response , '+90 days' ) ; } if ( $ action_result -> getCurrentPage ( ) && $ action_result -> getItemsPerPage ( ) ) { $ response = $ response -> withHeader ( 'X-PaginationCurrentPage' , $ action_result -> getCurrentPage ( ) ) -> withHeader ( 'X-PaginationItemsPerPage' , $ action_result -> getItemsPerPage ( ) ) -> withHeader ( 'X-PaginationTotalItems' , $ action_result -> count ( ) ) ; } else { $ response = $ response -> withHeader ( 'X-PaginationCurrentPage' , 0 ) -> withHeader ( 'X-PaginationItemsPerPage' , 0 ) -> withHeader ( 'X-PaginationTotalItems' , $ action_result -> count ( ) ) ; } return $ response ; }
Encode DataObject collection.

@param  CollectionInterface $action_result
@param  ResponseInterface   $response
@return ResponseInterface
Encode DataObject collection .