@param \Spryker\Glue\GlueApplication\Rest\JsonApi\RestResourceInterface[] $resources
@param \Spryker\Glue\GlueApplication\Rest\Request\Data\RestRequestInterface $restRequest

@return \Spryker\Glue\GlueApplication\Rest\JsonApi\RestResourceInterface[]
343455
public function addResourceRelationships(array $resources, RestRequestInterface $restRequest): array
    {
        foreach ($resources as $resource) {
            /**
             * @var \Generated\Shared\Transfer\CompanyUserTransfer|null $payload
             */
            $payload = $resource->getPayload();

            if ($payload === null || !($payload instanceof CompanyUserTransfer)) {
                continue;
            }

            $companyTransfer = $payload->getCompany();

            if ($companyTransfer === null) {
                continue;
            }

            $restCompanyAttributesTransfer = $this->companiesMapper
                ->mapCompanyTransferToRestCompaniesResponseAttributesTransfer(
                    $companyTransfer,
                    new RestCompaniesResponseAttributesTransfer()
                );

            $companyResource = $this->restResourceBuilder->createRestResource(
                CompaniesRestApiConfig::RESOURCE_COMPANIES,
                $companyTransfer->getUuid(),
                $restCompanyAttributesTransfer
            );

            $resource->addRelationship($companyResource);
        }
        return $resources;
    }
608375
public function getResources(
        ResourceTransformer $resourceTransformer,
        ResourceDefinition $resourceDefinition,
        Context $context,
        $request = null
    ) {
        if (!$this->hasApplicableContentType()) {
            return;
        }

        // @TODO this can probably be improved at some point
        $content = $this->getPostFromRequest($request);

        $resource = $resourceTransformer->fromArray(
            $resourceDefinition,
            $content,
            $context
        );

        $resourceCollection = $resourceTransformer->getResourceFactory()->createResourceCollection();
        $resourceCollection->add($resource);

        return $resourceCollection;
    }
59188
public function search(RestParams $restParams, $returnAll = false)
    {
        if ($restParams->getRepositoryMethod()) {
            return $this->callRepositoryMethod($restParams, $returnAll);
        }

        return $this->repository->search(
            $restParams->getConditions(),
            $restParams->getSorts(),
            $restParams->getJoins(),
            $returnAll ? null : $restParams->getPager(),
            $restParams->getMode()
        );
    }
386110
public function load($resource, array $filters = array())
    {
        $filters = array_merge($this->filters, $filters);

        $matches = array();
        if (preg_match('/^(.*)\:(\d+)-(\d+|\*)$/', $resource, $matches)) {
            $resource = $matches[1];
            $filters[] = new LineRangeFilter($matches[2], $matches[3]);
        } elseif (preg_match('/^(.*)\:(\d+)$/', $resource, $matches)) {
            $resource = $matches[1];
            $filters[] = new LineFilter($matches[2]);
        }

        $loader = $this->resolveLoader($resource);

        if (null === $loader) {
            return array();
        }

        $features = array();
        foreach ($loader->load($resource) as $feature) {
            foreach ($filters as $filter) {
                $feature = $filter->filterFeature($feature);

                if (!$feature->hasScenarios() && !$filter->isFeatureMatch($feature)) {
                    continue 2;
                }
            }

            $features[] = $feature;
        }

        return $features;
    }
475516
protected function getResourceAction($resource, $controller, $method, $options)
    {
        $name = $this->getResourceName($resource, $method, $options);

        return array('as' => $name, 'uses' => $controller .'@' .$method);
    }
582469
public function getListPaginate(HCResourceGrabPropertyRequest $request): JsonResponse
   {
       return response()->json(
           $this->service->getRepository()->getListPaginate($request)
       );
   }
598444
protected function filterParsers(RestRequestContract $request)
    {
        return [
            new SearchFilterParser($request, $this->getStringFilterField()),
            new ArrayFilterParser($request, $this->getArrayFilterFields()),
        ];
    }
805931
protected function handleResource(array $resources)
    {
        $found = array_by_key_value($resources, 'name', $this->resource);
        if (!isset($found, $found['class_name'])) {
            throw new NotFoundException("Resource '{$this->resource}' not found for service '{$this->name}'.");
        }

        $className = $found['class_name'];

        if (!class_exists($className)) {
            throw new InternalServerErrorException('Service configuration class name lookup failed for resource ' .
                $this->resourcePath);
        }

        /** @var ResourceInterface $resource */
        $resource = $this->instantiateResource($className, $found);

        $newPath = $this->resourceArray;
        array_shift($newPath);
        $newPath = implode('/', $newPath);

        return $resource->handleRequest($this->request, $newPath);
    }
1125514
private function handleGetRequest(Rest\RestRequest $request)
    {
        if (true === $request->hasIdentifier()) {
            if (false === $request->isRelationship() && false === $request->hasFilters()) {
                return $this->findRecord($request->getEntityType(), $request->getIdentifier());
            }
            if (true === $request->isRelationshipRetrieve()) {
                return $this->findRelationship($request->getEntityType(), $request->getIdentifier(), $request->getRelationshipFieldKey());
            }
            throw AdapterException::badRequest('No GET handler found.');
        } else {
            if (true === $request->isAutocomplete()) {
                // @todo Eventually add pagination (limit/skip)
                return $this->autocomplete($request->getEntityType(), $request->getAutocompleteKey(), $request->getAutocompleteValue());
            }
            if (true === $request->isQuery()) {
                return $this->findQuery($request->getEntityType(), $request->getQueryCriteria(), $request->getFieldset(), $request->getSorting(), $request->getPagination(), $request->getInclusions());
            }
            return $this->findAll($request->getEntityType(), [], $request->getFieldset(), $request->getSorting(), $request->getPagination(), $request->getInclusions());
        }
        throw AdapterException::badRequest('No GET handler found.');
    }
1019463
protected function getRestResource()
    {
        $parentResource = $this->getParentResource();

        if ($parentResource !== null) {
            $childResource = $parentResource->getChildResource($this->matchingUrl);
            if ($childResource) {
                $childResource->setUrlHandler($this);
                return $childResource;
            }
        }

        $className = $this->apiResourceClassName;
        /** @var RestResource $resource */
        $resource = new $className($this->getParentResource());
        $resource->setUrlHandler($this);

        return $resource;
    }
435271
public function setRequest(JsonRequest $request)
    {
        $this->id = $request->getId();
        $this->jsonrpc = $request->getJsonrpc();
        $this->method = $request->getMethod();
        $this->request = $request;

        if (!$request->getResponse()) {
            $request->setResponse($this);
        }

        return $this;
    }
793584
public function resource(
        RestRequestContract $request,
        ResourceInterface   $resource = null,
        int                 $httStatus = RestResponse::HTTP_OK,
        array               $headers = []
    ) {
        $data = $resource ? $this->fractal($request)->createData($resource)->toArray() : null;

        return RestResponse::create($data, $httStatus, $headers);
    }
82682
public RestRepositories getRepositories( HttpServletRequest request ) {
        RestRepositories repositories = new RestRepositories();
        for (String repositoryName : RepositoryManager.getJcrRepositoryNames()) {
            addRepository(request, repositories, repositoryName);
        }
        return repositories;
    }
683621
public function findCompanyBusinessUnitByExternalReference(RestRequestInterface $restRequest): RestResponseInterface
    {
        $restResponse = $this->restResourceBuilder->createRestResponse();

        if (!$restRequest->getResource()->getId()) {
            return $this->restApiError->addExternalReferenceMissingError($restResponse);
        }

        $restCompanyBusinessUnitsRequestAttributesTransfer = new RestCompanyBusinessUnitsRequestAttributesTransfer();
        $restCompanyBusinessUnitsRequestAttributesTransfer->setExternalReference($restRequest->getResource()->getId());

        $restCompanyBusinessUnitsResponseTransfer = $this->companyBusinessUnitsRestApiClient
            ->findCompanyBusinessUnitByExternalReference($restCompanyBusinessUnitsRequestAttributesTransfer);

        if (!$restCompanyBusinessUnitsResponseTransfer->getIsSuccess()) {
            return $this->createLoadCompanyBusinessUnitFailedErrorResponse($restCompanyBusinessUnitsResponseTransfer);
        }

        return $this->createCompanyBusinessUnitLoadedResponse($restCompanyBusinessUnitsResponseTransfer);
    }
719054
protected function createResourcesFromJsonData(array $data, ResponseInterface $response, ApiResourceInterface $owner)
    {
        $items = [];
        $className = $this->resourceClass();

        foreach ($data as $item) {
            $items[] = new $className($owner->getApi(), $item, $owner);
        }

        return $items;
    }
597016
protected function prepareResponse($responseRaw, RestRequest $request)
    {
        $body = (string) $responseRaw->getBody();
        
        $parsedResult = json_decode($body);
        if ($parsedResult == false) {
            $parsedResult = new \stdClass();
        }
        
        $response = new RestResponse($responseRaw->getStatusCode(), $body, $parsedResult, $request);
        
        return $response;
    }
1058475
public function onKernelRequest(RestEvent $event)
    {
        $rqlQuery = $event->getRequest()->attributes->get('rqlQuery');
        if ($rqlQuery === null) {
            return;
        }

        $route = $event->getRequest()->attributes->get('_route');
        if (substr($route, -4) !== '.get') {
            return;
        }

        foreach (['getQuery', 'getSort', 'getLimit'] as $method) {
            /** @var AbstractNode $node */
            $node = $rqlQuery->$method();
            if ($node === null) {
                continue;
            }

            throw new RqlOperatorNotAllowedException($node->getNodeName());
        }
    }