@param RestRequestContract $request

@return RestResponse
429011
public function handle($request)
    {
        $entity = $this->repository()->findById($request->getId());

        $this->authorize($request, $entity);

        $resource = new Item($entity, $this->transformer(), $entity->getResourceKey());

        return $this->response()->resource($request, $resource);
    }
945674
public function toRestResponse(int$status = 200, array $headers = []): RestResponseContract
	{
		return (new Response())->setData($this->toArray())->setStatus($status)->setHeaders($headers);
	}
134841
public function execute( Request $request )
    {
        $controllerClass = $request->attributes->get('_controller');
        if( !($this->isJwtRequired($controllerClass))) {
            return null;
        }

        if( !$this->authoriser->isAuthorised( $request ) ) {
            return new JsonResponse( ['error' => 'Invalid token'], 403 );
        }
        return null;
    }
1008938
public function send(Request $request)
    {
        $httpRequest  = $this->createHttpRequest($request);
        $httpResponse = $this->client->send($httpRequest);
        $code         = $httpResponse->getStatusCode();
        $response     = new PutResponse();

        if ( ! isset($this->validResponseCodes[$code])) {
            throw RiakTransportException::unexpectedStatusCode($code);
        }

        $contentList = $this->getRiakContentList($httpResponse);
        $vClock      = $httpResponse->getHeader('X-Riak-Vclock');
        $key         = null;

        if ($httpResponse->hasHeader('Location')) {
            $location = $httpResponse->getHeader('Location');
            $key      = substr($location, strrpos($location, '/') + 1);
        }

        $response->key         = $key;
        $response->vClock      = $vClock;
        $response->contentList = $contentList;

        return $response;
    }
598444
protected function filterParsers(RestRequestContract $request)
    {
        return [
            new SearchFilterParser($request, $this->getStringFilterField()),
            new ArrayFilterParser($request, $this->getArrayFilterFields()),
        ];
    }
235860
public function handle($request)
    {
        $entity = $this->repository()->findById($request->getId());

        $this->authorize($request, $entity);

        $this->setProperty($entity, $this->field(), null);

        $this->repository()->getEntityManager()->flush($entity);

        return $this->response()->noContent();
    }
287972
public function cgetAction(Request $request)
    {
        $locale = $this->getRequestParameter($request, 'locale', true);

        $restHelper = $this->get('sulu_core.list_rest_helper');

        /** @var Manager $manager */
        $manager = $this->get('es.manager.default');
        $repository = $manager->getRepository($this->get('sulu_article.view_document.factory')->getClass('article'));
        $search = $repository->createSearch();

        $limit = (int) $restHelper->getLimit();
        $page = (int) $restHelper->getPage();

        if (null !== $locale) {
            $search->addQuery(new TermQuery('locale', $locale));
        }

        if (count($ids = array_filter(explode(',', $request->get('ids', ''))))) {
            $search->addQuery(new IdsQuery($this->getViewDocumentIds($ids, $locale)));
            $limit = count($ids);
        }

        if (!empty($searchPattern = $restHelper->getSearchPattern())
            && 0 < count($searchFields = $restHelper->getSearchFields())
        ) {
            $boolQuery = new BoolQuery();
            foreach ($searchFields as $searchField) {
                $boolQuery->add(new MatchPhrasePrefixQuery($searchField, $searchPattern), BoolQuery::SHOULD);
            }
            $search->addQuery($boolQuery);
        }

        if (null !== ($type = $request->get('type'))) {
            $search->addQuery(new TermQuery('type', $type));
        }

        if ($contactId = $request->get('contactId')) {
            $boolQuery = new BoolQuery();
            $boolQuery->add(new MatchQuery('changer_contact_id', $contactId), BoolQuery::SHOULD);
            $boolQuery->add(new MatchQuery('creator_contact_id', $contactId), BoolQuery::SHOULD);
            $boolQuery->add(new MatchQuery('author_id', $contactId), BoolQuery::SHOULD);
            $search->addQuery($boolQuery);
        }

        if ($categoryId = $request->get('categoryId')) {
            $search->addQuery(new TermQuery('excerpt.categories.id', $categoryId), BoolQuery::MUST);
        }

        if ($tagId = $request->get('tagId')) {
            $search->addQuery(new TermQuery('excerpt.tags.id', $tagId), BoolQuery::MUST);
        }

        if ($pageId = $request->get('pageId')) {
            $search->addQuery(new TermQuery('parent_page_uuid', $pageId), BoolQuery::MUST);
        }

        if ($workflowStage = $request->get('workflowStage')) {
            $search->addQuery(new TermQuery('published_state', 'published' === $workflowStage), BoolQuery::MUST);
        }

        if ($this->getBooleanRequestParameter($request, 'exclude-shadows', false, false)) {
            $search->addQuery(new TermQuery('localization_state.state', 'shadow'), BoolQuery::MUST_NOT);
        }

        if ($this->getBooleanRequestParameter($request, 'exclude-ghosts', false, false)) {
            $search->addQuery(new TermQuery('localization_state.state', 'ghost'), BoolQuery::MUST_NOT);
        }

        $authoredFrom = $request->get('authoredFrom');
        $authoredTo = $request->get('authoredTo');
        if ($authoredFrom || $authoredTo) {
            $search->addQuery($this->getRangeQuery('authored', $authoredFrom, $authoredTo), BoolQuery::MUST);
        }

        if (null === $search->getQueries()) {
            $search->addQuery(new MatchAllQuery());
        }

        if (null !== $restHelper->getSortColumn() &&
            $sortField = $this->getSortFieldName($restHelper->getSortColumn())
        ) {
            $search->addSort(
                new FieldSort($sortField, $restHelper->getSortOrder())
            );
        }

        $fieldDescriptors = $this->getFieldDescriptors();

        if ($limit) {
            $search->setSize($limit);
            $search->setFrom(($page - 1) * $limit);

            $fields = array_merge(
                $restHelper->getFields() ?: [],
                ['id', 'localizationState', 'publishedState', 'published']
            );
            $fieldDescriptors = array_filter(
                $fieldDescriptors,
                function (FieldDescriptorInterface $fieldDescriptor) use ($fields) {
                    return in_array($fieldDescriptor->getName(), $fields);
                }
            );
        } else {
            $search->setSize(1000);
            $search->setScroll('1m');
        }

        $searchResult = $repository->findRaw($search);
        $result = [];
        foreach ($searchResult as $document) {
            $documentData = $this->normalize($document['_source'], $fieldDescriptors);
            if (false !== ($index = array_search($documentData['id'], $ids))) {
                $result[$index] = $documentData;
            } else {
                $result[] = $documentData;
            }
        }

        if (count($ids)) {
            ksort($result);
            $result = array_values($result);
        }

        $count = $searchResult->count();

        return $this->handleView(
            $this->view(
                new ListRepresentation(
                    $result,
                    'articles',
                    'get_articles',
                    $request->query->all(),
                    $page,
                    $limit,
                    $count
                )
            )
        );
    }
464439
public function send(Request $request)
    {
        $response     = new PutSchemaResponse();
        $httpRequest  = $this->createHttpRequest($request);

        $this->client->send($httpRequest);

        return $response;
    }
1279098
public function sendRequest(Request $request)
    {
        $response = $this->httpClient->send($request);

        $this->checkErrorResponse($response);

        return $response;
    }
1045447
private function createRpbMessage(GetRequest $request)
    {
        $rpbRequest = new DtFetchReq();

        $rpbRequest->setBucket($request->bucket);
        $rpbRequest->setType($request->type);
        $rpbRequest->setKey($request->key);

        if ($request->r !== null) {
            $rpbRequest->setR($this->encodeQuorum($request->r));
        }

        if ($request->pr !== null) {
            $rpbRequest->setPr($this->encodeQuorum($request->pr));
        }

        if ($request->basicQuorum !== null) {
            $rpbRequest->setBasicQuorum($request->basicQuorum);
        }

        if ($request->notfoundOk !== null) {
            $rpbRequest->setNotfoundOk($request->notfoundOk);
        }

        if ($request->includeContext !== null) {
            $rpbRequest->setIncludeContext($request->includeContext);
        }

        return $rpbRequest;
    }
1285830
public function send(Request $request)
    {
        $response    = new GetResponse();
        $httpRequest = $this->createHttpRequest($request);

        try {
            $httpResponse = $this->client->send($httpRequest);
            $code         = $httpResponse->getStatusCode();
        } catch (RequestException $e) {
            if ($e->getCode() == 404 && $request->notfoundOk) {
                return $response;
            }

            throw $e;
        }

        if ( ! isset($this->validResponseCodes[$code])) {
            throw RiakTransportException::unexpectedStatusCode($code);
        }

        $json    = $httpResponse->json();
        $context = isset($json['context']) ? $json['context'] : null;
        $value   = $json['value'];
        $type    = $json['type'];

        $response->type    = $type;
        $response->context = $context;
        $response->value   = $this->opConverter->fromArray($type, $value);

        return $response;
    }
251393
public function handleQuery(HTTPRequest $request)
    {
        //get requested model(s) details
        $model = $request->param('ModelReference');

        $modelMap = Config::inst()->get(self::class, 'models');

        if (array_key_exists($model, $modelMap)) {
            $model = $modelMap[$model];
        }

        $id = $request->param('ID');
        $response = false;
        $queryParams = $this->parseQueryParameters($request->getVars());

        //validate Model name + store
        if ($model) {
            $model = $this->deSerializer->unformatName($model);
            if (!class_exists($model)) {
                return new RESTfulAPIError(400,
                    "Model does not exist. Received '$model'."
                );
            } else {
                //store requested model data and query data
                $this->requestedData['model'] = $model;
            }
        } else {
            //if model missing, stop + return blank object
            return new RESTfulAPIError(400,
                "Missing Model parameter."
            );
        }

        //check API access rules on model
        if (!RESTfulAPI::api_access_control($model, $request->httpMethod())) {
            return new RESTfulAPIError(403,
                "API access denied."
            );
        }

        //validate ID + store
        if (($request->isPUT() || $request->isDELETE()) && !is_numeric($id)) {
            return new RESTfulAPIError(400,
                "Invalid or missing ID. Received '$id'."
            );
        } elseif ($id !== null && !is_numeric($id)) {
            return new RESTfulAPIError(400,
                "Invalid ID. Received '$id'."
            );
        } else {
            $this->requestedData['id'] = $id;
        }

        //store query parameters
        if ($queryParams) {
            $this->requestedData['params'] = $queryParams;
        }

        //map HTTP word to module method
        switch ($request->httpMethod()) {
            case 'GET':
                return $this->findModel($model, $id, $queryParams, $request);
                break;
            case 'POST':
                return $this->createModel($model, $request);
                break;
            case 'PUT':
                return $this->updateModel($model, $id, $request);
                break;
            case 'DELETE':
                return $this->deleteModel($model, $id, $request);
                break;
            default:
                return new RESTfulAPIError(403,
                    "HTTP method mismatch."
                );
                break;
        }
    }
987391
protected function doRequest($request)
    {
        $response = $this->kernel->handle($request, HttpKernelInterface::MASTER_REQUEST, $this->catchExceptions);

        if ($this->kernel instanceof TerminableInterface) {
            $this->kernel->terminate($request, $response);
        }

        return $response;
    }
905262
public function send(Request $request)
    {
        $response   = new PutResponse();
        $rpbPutReq  = $this->createRpbMessage($request);
        $rpbPutResp = $this->client->send($rpbPutReq, RiakMessageCodes::PUT_REQ, RiakMessageCodes::PUT_RESP);

        if ( ! $rpbPutResp instanceof RpbPutResp) {
            return $response;
        }

        if ( ! $rpbPutResp->hasContent()) {
            return $response;
        }

        if ($rpbPutResp->hasKey()) {
            $response->key = $rpbPutResp->key;
        }

        $response->vClock      = $rpbPutResp->getVclock()->get();
        $response->contentList = $this->createContentList($rpbPutResp->getContentList());

        return $response;
    }
338339
protected static function fractal(RestRequestContract $request)
    {
        $fractal = new Manager(new ScopeFactory(), $request);
        $fractal->setSerializer(new JsonApiSerializer($request));

        if ($includes = $request->getInclude()) {
            $fractal->parseIncludes($includes);
        }

        if ($excludes = $request->getExclude()) {
            $fractal->parseExcludes($excludes);
        }

        if ($fields = $request->getFields()) {
            $fractal->parseFieldsets($fields);
        }

        return $fractal;
    }
654434
public function toResponse($request)
    {
        return tap(response()->json(
            $this->wrap(
                $this->resource->resolve($request),
                array_merge_recursive(
                    $this->paginationInformation($request),
                    $this->resource->with($request),
                    $this->resource->additional
                )
            ),
            $this->calculateStatus()
        ), function ($response) use ($request) {
            $response->original = $this->resource->resource->pluck('resource');

            $this->resource->withResponse($request, $response);
        });
    }
1302215
public function cgetAction(Request $request)
    {
        if ('true' == $request->get('flat')) {
            /** @var RestHelperInterface $restHelper */
            $restHelper = $this->get('sulu_core.doctrine_rest_helper');

            /** @var DoctrineListBuilderFactory $factory */
            $factory = $this->get('sulu_core.doctrine_list_builder_factory');

            $tagEntityName = $this->getParameter('sulu.model.tag.class');

            $fieldDescriptors = $this->get('sulu_core.list_builder.field_descriptor_factory')
                ->getFieldDescriptors('tags');
            $listBuilder = $factory->create($tagEntityName);

            $names = array_filter(explode(',', $request->get('names', '')));
            if (count($names) > 0) {
                $listBuilder->in($fieldDescriptors['name'], $names);
            }

            $restHelper->initializeListBuilder($listBuilder, $fieldDescriptors);

            $list = new ListRepresentation(
                $listBuilder->execute(),
                self::$entityKey,
                'get_tags',
                $request->query->all(),
                $listBuilder->getCurrentPage(),
                $listBuilder->getLimit(),
                $listBuilder->count()
            );
            $view = $this->view($list, 200);
        } else {
            $list = new CollectionRepresentation($this->getManager()->findAll(), self::$entityKey);

            $context = new Context();
            $context->setGroups(['partialTag']);
            $view = $this->view($list, 200)->setContext($context);
        }

        return $this->handleView($view);
    }