Returns the correct object, according to the 'isBatchPart' option.
If it is a Batchpart, it returns the request object, else the response.

@param AbstractHttpRequest $request

@return mixed
763188
public function getReturnObject($request)
    {
        if (array_key_exists('isBatchPart', $request->options) && $request->options['isBatchPart'] === true) {
            return $request;
        } else {
            return $request->send();
        }
    }
835302
public function get(Request $request, Fractal $fractal, FractalCollection $collection)
    {
        $this->beforeRequest($request, func_get_args());
        $transformer = $this->getTransformer();
        $includes = $request->input('include', '');
        $filter = $request->input('filter', false);
        $items = $this->getRepository();
        if ($filter && is_string($filter)) {
            $filter = json_decode($filter, true);
        }
        $queryFilter = [];
        if (!empty($filter)) {
            $queryFilter = new QueryFilter($filter, $items->model(), $this->getTransformer()); 
        }
        $fractal->parseIncludes($includes);
        $resource = $collection->setTransformer($transformer)->setResourceKey($this->getResourceKey());
        $paginator = $items->paginate($queryFilter, $transformer->getSafeEagerLoad($fractal->getRequestedIncludes()), app('context'));
        $itemCollection = $paginator->getCollection();
        $resource->setData($itemCollection);
        $resource->setPaginator(new IlluminatePaginatorAdapter($paginator));
        return $this->respondWithCollection($fractal->createData($resource));
    }
331337
public function getAction(Request $request)
    {
        $filename = $request->get('file');
        $filename = $this->container->getParameter('phlexible_media_template.previewer.temp_dir').basename($filename);

        $file = new File($filename);

        return new BinaryFileResponse($file);
    }
124374
private function getBuiltObject(
        Request $request,
        FormFactoryInterface $formFactory,
        CreateForm $annotation,
        string $parameterClass,
        AbstractType $type
    ) {
        /**
         * Checks if parameter typehinting is AbstractType
         * In this case, form type as defined method parameter.
         */
        if (AbstractType::class == $parameterClass) {
            return $type;
        }

        $entity = $request->attributes->get($annotation->getEntity());

        /**
         * Creates form object from type.
         */
        $form = $formFactory->create(get_class($type), $entity);

        /**
         * Handling request if needed.
         */
        if ($annotation->getHandleRequest()) {
            $form->handleRequest($request);

            if ($annotation->getValidate()) {
                $request->attributes->set(
                    $annotation->getValidate(),
                    ($form->isSubmitted() && $form->isValid())
                );
            }
        }

        /**
         * Checks if parameter typehinting is Form
         * In this case, inject form as defined method parameter.
         */
        if (in_array(
            $parameterClass, [
                Form::class,
                FormInterface::class,
            ]
        )) {
            return $form;
        }

        /**
         * Checks if parameter typehinting is FormView
         * In this case, inject form's view as defined method parameter.
         */
        if (FormView::class == $parameterClass) {
            return $form->createView();
        }
    }
7627
public function process(ServerRequestInterface $request, DelegateInterface $delegate)
    {
        $uriPath = $request->getUri()->getPath();

        /** @var Description $description */
        foreach ($this->repository as $description) {

            $basePath = $description->getBasePath() ? "{$description->getBasePath()}/" : "";

            foreach ($description->getPaths() as $path) {
                $pathPattern = "$basePath{$path->getPath()}";

                $parameterNames = [];
                foreach ($path->getOperations() as $operation) {
                    foreach ($operation->getParameters() as $parameter) {
                        if ($parameter->getIn() === Parameter::IN_PATH
                            && ($schema = $parameter->getSchema()) instanceof ScalarSchema
                        ) {
                            $parameterName    = $parameter->getName();
                            $parameterNames[] = $parameterName;
                            $typePattern      = $this->typePatternResolver->resolve($schema);
                            $parameterPattern = "(?P<$parameterName>$typePattern)(?=(/|$))";
                            $pathPattern      = str_replace('{' . $parameterName . '}', $parameterPattern, $pathPattern);
                        }
                    }

                    if (preg_match("#^$pathPattern$#", $uriPath, $matches) > 0) {
                        if (strtolower($request->getMethod()) !== $operation->getMethod()) {
                            return Factory::createResponse(405);
                        }

                        $request = Meta::requestWith($request, $description, $operation, $path);

                        foreach ($parameterNames as $parameterName) {
                            $request = $request->withAttribute($parameterName, $matches[$parameterName]);
                        }

                        return $delegate->process($request);
                    }
                }

            }
        }

        return Factory::createResponse(404);
    }
416845
public static function build(AbstractRequest $request)
    {
        $name = get_class($request);
        if (!isset(self::$loaded[$name])) {
            self::$loaded[$name] = new CurlHandle();
        } else {
            self::$loaded[$name]->reset();
        }
        self::$loaded[$name]->prepare($request);

        return self::$loaded[$name];
    }
480335
public function toResponse($request)
    {
        return (
            $this->resource instanceof AbstractPaginator
                ? new PaginatedResourceResponse($this)
                : new ResourceResponse($this)
        )->toResponse($request);
    }
1288725
private function getRequest()
    {
        $error = null;

        do {
            if (array_key_exists('REQUEST_METHOD', $_SERVER) && $_SERVER['REQUEST_METHOD'] != 'POST') {
                $error = self::INVALIDREQUEST;
                break;
            };

            $request = !empty($_GET['rawRequest']) ? $_GET['rawRequest'] : file_get_contents('php://input');
            $this->request = json_decode($request, false);
            if ($this->request === null) {
                $error = self::PARSEERROR;
                break;
            }

            if ($this->request === []) {
                $error = self::INVALIDREQUEST;
                break;
            }

            // check for batch call
            if (is_array($this->request)) {
                if (count($this->request) > $this->MaxBatchCalls) {
                    $error = self::INVALIDREQUEST;
                    break;
                }

                $this->calls = $this->request;
                $this->isBatchCall = true;
            } else {
                $this->calls[] = $this->request;
            }
        } while (false);

        return $error;
    }
1243434
public function sendBatchRequest(BatchRequest $request)
    {
        $response = $this->sendRequest($request);

        return new BatchResponse($request, $response);
    }
295307
private function getParsedBody(Request $request): array
    {
        $contentType = \explode(';', (string) $request->headers->get('content-type'), 2)[0];

        // JSON object
        switch ($contentType) {
            case static::CONTENT_TYPE_JSON:
                $parsedBody = \json_decode($request->getContent(), true);

                if (\JSON_ERROR_NONE !== \json_last_error()) {
                    throw new BadRequestHttpException('POST body sent invalid JSON');
                }
                break;

            case static::CONTENT_TYPE_FORM_DATA:
                $parsedBody = $this->handleUploadedFiles($request->request->all(), $request->files->all());
                break;

            default:
                throw new BadRequestHttpException(\sprintf(
                    'Batching parser only accepts "%s" or "%s" content-type but got %s.',
                    static::CONTENT_TYPE_JSON,
                    static::CONTENT_TYPE_FORM_DATA,
                    \json_encode($contentType)
                ));
        }

        return $parsedBody;
    }
588518
public function getRequest( Request $request ) {
		$response = $this->getClient()->request(
			'GET',
			$this->apiUrl,
			$this->getClientRequestOptions( $request, 'query' )
		);

		return $this->decodeResponse( $response );
	}
701060
protected function chain(Request $request)
	{
		if (is_object($this->adaptorNext)) {
			if (method_exists($this->adaptorNext, 'handle')) {
				return $this->adaptorNext->handle($request);
			}
			if (method_exists($this->adaptorNext, 'process')) {
				return $this->adaptorNext->process($request);
			}
		}
		$next = $this->adaptorNext;
		if ($this->adaptorResponse !== null) {
			return $next($request, $this->adaptorResponse);
		}
		return $next($request);
	}
1205117
public function sendBatchRequest(array $requests)
    {
        $batchRequest = new BatchRequest($this->endpoint, $this->secret, $requests);

        return $this->lastResponse = $this->client->sendBatchRequest($batchRequest);
    }
1324128
protected function doRequest($request)
    {
        $slimRequest = $this->convertRequest($request);

        $container = $this->app->getContainer();

        /* @var $slimResponse ResponseInterface */
        $slimResponse = $container->get('response');

        // reset body stream
        $slimResponse = $slimResponse->withBody(new Stream(fopen('php://temp', 'w+')));

        $slimResponse = $this->app->process($slimRequest, $slimResponse);

        return new BrowserKitResponse(
            (string) $slimResponse->getBody(),
            $slimResponse->getStatusCode(),
            $slimResponse->getHeaders()
        );
    }
777058
public function batchAction()
    {
        $request = $this->getRequest();
        $restMethod = $this->getRestMethod();

        if ('POST' !== $restMethod) {
            throw $this->createNotFoundException(sprintf('Invalid request type "%s", POST expected', $restMethod));
        }

        // check the csrf token
        $this->validateCsrfToken('sonata.batch');

        $confirmation = $request->get('confirmation', false);

        if ($data = json_decode((string) $request->get('data'), true)) {
            $action = $data['action'];
            $idx = $data['idx'];
            $allElements = $data['all_elements'];
            $request->request->replace(array_merge($request->request->all(), $data));
        } else {
            $request->request->set('idx', $request->get('idx', []));
            $request->request->set('all_elements', $request->get('all_elements', false));

            $action = $request->get('action');
            $idx = $request->get('idx');
            $allElements = $request->get('all_elements');
            $data = $request->request->all();

            unset($data['_sonata_csrf_token']);
        }

        // NEXT_MAJOR: Remove reflection check.
        $reflector = new \ReflectionMethod($this->admin, 'getBatchActions');
        if ($reflector->getDeclaringClass()->getName() === \get_class($this->admin)) {
            @trigger_error('Override Sonata\AdminBundle\Admin\AbstractAdmin::getBatchActions method'
                .' is deprecated since version 3.2.'
                .' Use Sonata\AdminBundle\Admin\AbstractAdmin::configureBatchActions instead.'
                .' The method will be final in 4.0.', E_USER_DEPRECATED
            );
        }
        $batchActions = $this->admin->getBatchActions();
        if (!\array_key_exists($action, $batchActions)) {
            throw new \RuntimeException(sprintf('The `%s` batch action is not defined', $action));
        }

        $camelizedAction = Inflector::classify($action);
        $isRelevantAction = sprintf('batchAction%sIsRelevant', $camelizedAction);

        if (method_exists($this, $isRelevantAction)) {
            $nonRelevantMessage = \call_user_func([$this, $isRelevantAction], $idx, $allElements, $request);
        } else {
            $nonRelevantMessage = 0 !== \count($idx) || $allElements; // at least one item is selected
        }

        if (!$nonRelevantMessage) { // default non relevant message (if false of null)
            $nonRelevantMessage = 'flash_batch_empty';
        }

        $datagrid = $this->admin->getDatagrid();
        $datagrid->buildPager();

        if (true !== $nonRelevantMessage) {
            $this->addFlash(
                'sonata_flash_info',
                $this->trans($nonRelevantMessage, [], 'SonataAdminBundle')
            );

            return $this->redirectToList();
        }

        $askConfirmation = $batchActions[$action]['ask_confirmation'] ??
            true;

        if ($askConfirmation && 'ok' !== $confirmation) {
            $actionLabel = $batchActions[$action]['label'];
            $batchTranslationDomain = $batchActions[$action]['translation_domain'] ??
                $this->admin->getTranslationDomain();

            $formView = $datagrid->getForm()->createView();
            $this->setFormTheme($formView, $this->admin->getFilterTheme());

            // NEXT_MAJOR: Remove these lines and use commented lines below them instead
            $template = !empty($batchActions[$action]['template']) ?
                $batchActions[$action]['template'] :
                $this->admin->getTemplate('batch_confirmation');
            // $template = !empty($batchActions[$action]['template']) ?
            //     $batchActions[$action]['template'] :
            //     $this->templateRegistry->getTemplate('batch_confirmation');

            return $this->renderWithExtraParams($template, [
                'action' => 'list',
                'action_label' => $actionLabel,
                'batch_translation_domain' => $batchTranslationDomain,
                'datagrid' => $datagrid,
                'form' => $formView,
                'data' => $data,
                'csrf_token' => $this->getCsrfToken('sonata.batch'),
            ], null);
        }

        // execute the action, batchActionXxxxx
        $finalAction = sprintf('batchAction%s', $camelizedAction);
        if (!method_exists($this, $finalAction)) {
            throw new \RuntimeException(sprintf('A `%s::%s` method must be callable', \get_class($this), $finalAction));
        }

        $query = $datagrid->getQuery();

        $query->setFirstResult(null);
        $query->setMaxResults(null);

        $this->admin->preBatchAction($action, $query, $idx, $allElements);

        if (\count($idx) > 0) {
            $this->admin->getModelManager()->addIdentifiersToQuery($this->admin->getClass(), $query, $idx);
        } elseif (!$allElements) {
            $this->addFlash(
                'sonata_flash_info',
                $this->trans('flash_batch_no_elements_processed', [], 'SonataAdminBundle')
            );

            return $this->redirectToList();
        }

        return \call_user_func([$this, $finalAction], $query, $request);
    }
55214
public function invoke(AbstractRequest $request)
    {
        $this->invoker->invoke($request);
        $current = clone $request->resourceObject;
        foreach ($request->links as $link) {
            /* @noinspection ExceptionsAnnotatingAndHandlingInspection */
            $nextResource = $this->annotationLink($link, $current, $request);
            $current = $this->nextLink($link, $current, $nextResource);
        }

        return $current;
    }
566551
public static function getResponder(Request $request)
    {
        if ($request instanceof HttpRequest) {
            return self::getHttpResponder($request);
        } else {
            $requestType = get_class($request);
            throw new \InvalidArgumentException("Requests of type '{$requestType}' are not supported.");
        }
    }