Return configured fractal by request format.

@param RestRequestContract $request

@return Manager
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;
    }
449921
public function head(Request $request, Fractal $fractal)
    {
        $this->beforeRequest($request, func_get_args());
        $id = $this->parseObjectId($request);
        $model = $this->loadAuthorizeObject($id, 'read');
        return $this->respondWithEmptyItem(
            $fractal->createData($this->getFractalItem($model))
        );
    }
342041
public function indexAction(Request $request)
    {
        $this->init($request);

        $nodeAdminListConfigurator = new NodeAdminListConfigurator(
            $this->em,
            $this->aclHelper,
            $this->locale,
            PermissionMap::PERMISSION_VIEW,
            $this->authorizationChecker
        );

        $locale = $this->locale;
        $acl = $this->authorizationChecker;
        $itemRoute = function (EntityInterface $item) use ($locale, $acl) {
            if ($acl->isGranted(PermissionMap::PERMISSION_VIEW, $item->getNode())) {
                return array(
                    'path' => '_slug_preview',
                    'params' => ['_locale' => $locale, 'url' => $item->getUrl()],
                );
            }
        };
        $nodeAdminListConfigurator->addSimpleItemAction('action.preview', $itemRoute, 'eye');
        $nodeAdminListConfigurator->setDomainConfiguration($this->get('kunstmaan_admin.domain_configuration'));
        $nodeAdminListConfigurator->setShowAddHomepage($this->getParameter('kunstmaan_node.show_add_homepage') && $this->isGranted('ROLE_SUPER_ADMIN'));

        /** @var AdminList $adminlist */
        $adminlist = $this->get('kunstmaan_adminlist.factory')->createList($nodeAdminListConfigurator);
        $adminlist->bindRequest($request);

        return array(
            'adminlist' => $adminlist,
        );
    }
1089920
private function getManager(Request $request)
    {
        if (!isset($this->managers[$request->get('manager')])) {
            throw new NotFoundHttpException(sprintf('The manager `%s` does not exist', $request->get('manager')));
        }

        return $this->managers[$request->get('manager')];
    }
1128533
public function toResponse($request)
    {
        return $this->resource instanceof AbstractPaginator
                    ? (new PaginatedResourceResponse($this))->toResponse($request)
                    : parent::toResponse($request);
    }
816120
protected function getParamLocale(HTTPRequest $request)
    {
        $queryParam = FluentDirectorExtension::config()->get('query_param');
        $locale = (string)($request->param($queryParam) ?: $request->requestVar($queryParam));
        return $locale;
    }
490557
public function createAction(Request $request)
    {
        $measureunit = new MeasureUnit();
        $form = $this->createForm(new MeasureUnitType(), $measureunit);
        if ($form->handleRequest($request)->isValid()) {
            $em = $this->getDoctrine()->getManager();
            $em->persist($measureunit);
            $em->flush();

            return $this->redirect($this->generateUrl('admin_shop_measure_unit_show', array('id' => $measureunit->getId())));
        }

        return array(
            'measureunit' => $measureunit,
            'form' => $form->createView(),
        );
    }
187269
public function store(Request $request)
    {
        $this->authorize('store', Location::class);
        /** @noinspection PhpUndefinedMethodInspection */
        $request->validate(['name' => 'required|max:128']);
        $location = new Location();
        $location->team_id = $this->userContext()->team_id;
        $location->name = $request->name;
        $location->save();
        return fractal($location, new LocationTransformer())
            ->withResourceName('location')
            ->respond();
    }
726318
public static function create_from_request($request) {
        if($type = $request->getVar('accept')) {
            try {
                if(array_key_exists($type, self::$lookup)) {
                    return self::create(self::$lookup[$type]);
                }
            } catch(\Exception $e) {}
        }
        $types = $request->getAcceptMimetypes();
        foreach($types as $type) {
            try {
                return self::create($type);
            } catch(RestUserException $e) {}
        }
        return self::create();
    }
838332
protected function applyPagination(RestRequestContract $request, QueryBuilder $qb)
    {
        $qb->addCriteria(
            new Criteria(null,
                $request->getOrderBy(),
                $request->getStart(),
                $request->getLimit()
            )
        );

        return $this;
    }
598444
protected function filterParsers(RestRequestContract $request)
    {
        return [
            new SearchFilterParser($request, $this->getStringFilterField()),
            new ArrayFilterParser($request, $this->getArrayFilterFields()),
        ];
    }
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;
    }
683672
public function store(Request $request)
    {
        /** @noinspection PhpUndefinedMethodInspection */
        $request->validate([
            'description' => 'max:256',
            'name' => 'required|max:32',
        ]);
        $memberTag = new MemberTag();
        $this->authorize('store', $memberTag);
        $memberTag->team_id = $this->userContext()->team_id;
        if ($request->has('description')) {
            $memberTag->description = $request->description;
        }
        $memberTag->name = $request->name;
        $memberTag->save();
        return fractal($memberTag, new MemberTagTransformer())
            ->withResourceName('memberTag')
            ->respond();
    }
884913
public function toResponse($request)
    {
        $transformer = app()->make(
            'InetStudio\PollsPackage\Polls\Contracts\Transformers\Back\Utility\SuggestionTransformerContract',
            [
                 'type' => $this->type,
             ]
        );

        $resource = $transformer->transformCollection($this->items);

        $serializer = app()->make('InetStudio\AdminPanel\Base\Contracts\Serializers\SimpleDataArraySerializerContract');

        $manager = new Manager();
        $manager->setSerializer($serializer);

        $transformation = $manager->createData($resource)->toArray();

        $data = [
            'suggestions' => [],
            'items' => [],
        ];

        if ($this->type == 'autocomplete') {
            $data['suggestions'] = $transformation;
        } else {
            $data['items'] = $transformation;
        }

        return response()->json($data);
    }
1372099
public static function proxy ($request) {

		if (!$request instanceof Request) {
			$url = $request;

			$request = new Request ();
			$request->setUrl ($url);
			$request->setMethod (Request::METHOD_GET);
		}

		return Client::getInstance ()->process ($request);
	}
753110
public function getAction(Request $request)
    {
        $handlerFactory = $this->get('task.handler.factory');
        $entityClass = $this->getRequestParameter($request, 'entity-class', true);

        $handlers = [];
        foreach ($handlerFactory->getHandlers() as $handler) {
            if ($handler instanceof AutomationTaskHandlerInterface && $handler->supports($entityClass)) {
                $configuration = $handler->getConfiguration();
                $handlers[] = ['id' => get_class($handler), 'title' => $configuration->getTitle()];
            }
        }

        return new JsonResponse(['_embedded' => ['handlers' => $handlers]]);
    }
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);
    }