@param Request        $request
@param ParamConverter $configuration

@return bool
10144
public function apply(Request $request, ParamConverter $configuration)
    {
        $fieldName = $this->getOptions($configuration)['type_field'];

        if ($fieldName) {
            $value = $request->attributes->get($fieldName);
            if (!$value) {
                throw new NotFoundHttpException(sprintf('Expected to have `%s` attribute present', $fieldName));
            }

            $className = $this->contentType->getContentTypeClass($value);

            if (null === $className) {
                throw new NotFoundHttpException(sprintf('Cannot guess page type from request: %s', $value));
            }

            $configuration->setClass($className);
        }

        return parent::apply($request, $configuration);
    }
335122
public function store(Request $request)
    {
        $config = $request->input('config');

        foreach (array_dot($request->input('data')) as $key => $value) {
            $path = $config . '.' . $key;
            $this->destroy($path);
            if (is_array($value)) {
                $value = implode(',', $value);
            }
            Configuration::create(['key' => $path, 'value' => $value]);
        }

        return $this->notifySuccess(trans('cms::config.success', ['config' => $config]));
    }
780
public function isMode( Configuration $configuration ) {
		if( $this->inServiceChecker->isInService($configuration) )
			return false;

		if( $this->replaceUpgradeChecker->isReplaceUpgrade($configuration) )
			return false;

		return true;
	}
86060
protected function handleChange(Request $request, RequestConfiguration $configuration, ChangeUser $data): Response
    {
        $user = $data->getUser();
        $dispatcher = $this->container->get('event_dispatcher');

        if ($data->isUsernameChanged()) {
            $dispatcher->dispatch(UserEvents::PRE_USERNAME_CHANGE, new GenericEvent($data));
            $user->setUsername($data->getUsername());
        }

        if ($data->isEmailChanged()) {
            $dispatcher->dispatch(UserEvents::PRE_EMAIL_CHANGE, new GenericEvent($data));
            $user->setEmail($data->getEmail());

            if ($this->container->get('chang.option_resolver')->get('user.verify_email_change.enabled')) {
                /** @var GeneratorInterface $tokenGenerator */
                $tokenGenerator = $this->container->get(sprintf('sylius.%s.token_generator.email_verification', $this->metadata->getName()));
                $user->setEmailVerificationToken($tokenGenerator->generate());
                $user->setVerifiedAt(null);
            }
        }

        $this->manager->flush();

        if ($data->isUsernameChanged()) {
            $dispatcher->dispatch(UserEvents::POST_USERNAME_CHANGE, new GenericEvent($data));
        }

        if ($data->isEmailChanged()) {
            $dispatcher->dispatch(UserEvents::POST_EMAIL_CHANGE, new GenericEvent($data));

            if ($user->getEmailVerificationToken()) {
                $dispatcher->dispatch(UserEvents::REQUEST_VERIFICATION_TOKEN, new GenericEvent($user));
            }
        }

        if (!$configuration->isHtmlRequest()) {
            return $this->viewHandler->handle($configuration, View::create(null, Response::HTTP_NO_CONTENT));
        }

        if ($data->isUserChanged()) {
            $this->addTranslatedFlash('success', 'chang.user.changed');
        }

        $redirectRouteName = $this->getSyliusAttribute($request, 'redirect', null);

        Assert::notNull($redirectRouteName, 'Redirect is not configured.');

        return $this->redirectHandler->redirectToResource($configuration, $user);
    }
21695
protected function isGrantedOr403(SyliusRequestConfiguration $configuration, string $permission): void
    {
        if (!$configuration->hasPermission()) {
            $permission = $this->getRoleName($permission);
            if (!$this->authorizationChecker->isGranted($configuration, $permission)) {
                throw $this->createAccessDeniedException();
            }
            return;
        }

        $permission = $configuration->getPermission($permission);
        if (!$this->authorizationChecker->isGranted($configuration, $permission)) {
            throw $this->createAccessDeniedException();
        }

        return;
    }
162456
public function apply(Request $request, ParamConverter $configuration)
    {
        if (null === $parameter = $configuration->getName()) {
            throw new InvalidConfigurationException(InvalidConfigurationException::MISSING_NAME);
        }

        $token = $this->tokenStorage->getToken();

        if ($token && ($user = $token->getUser()) instanceof User) {
            $request->attributes->set($parameter, $user);

            return true;
        }

        throw new AccessDeniedHttpException();
    }
1229018
public function handle(Request $request)
    {
        try {
            $this->loadConfiguration();

            // Now that Configuration is loaded let's resolve controller
            // for given request.
            $calls = $this->resolveController($request);
            $controller = $calls['controller'];
            $callable   = $calls['callable'];

            // Resolve arguments before calling controller
            $res = $controller->$callable();

            // Check if controller returned Response
            // and if so let's use it as our response
            if (is_a($res, 'Symfony\Component\HttpFoundation\Response')) {
                $this->response = $res;
            }

        } catch (\Exception $e) {
            $error = new \StdClass;
            $error->message = $e->getMessage();
            $error->code    = $e->getCode();
            $this->response->setStatusCode($e->getCode());
            $this->response->setContent(json_encode($error));
            $this->response->headers->set('Content-Type', 'application/json');
        }

        // Send response
        if ($request->getRequestFormat() == 'json') {
            $this->response->headers->set('Content-Type', 'application/json');
        }

        $this->response->send();

    }
113528
protected function resolveTargetEntity(ParamConverter $configuration)
    {
        $class = $configuration->getClass();
        if (isset($this->mapping[$class])) {
            if ($this->mapping[$class] !== $class) {
                $configuration->setClass($this->mapping[$class]);
            }
        }

        return $configuration;
    }
401667
public function toggleAction(Request $request)
    {
        $name = $request->get('name');
        try {
            $this->get('ongr_settings.settings_manager')->toggleExperiment($name);
        } catch (\Exception $e) {
            return new JsonResponse(['error' => true]);
        }

        return new JsonResponse(['error' => false]);
    }
1243196
private function getViolationDetector(Configuration $configuration)
    {
        $violationChecker = $this->getViolationChecker($configuration);
        $violationFilter = $this->getViolationFilter($configuration);

        return new ViolationDetector(
            $violationChecker,
            $violationFilter
        );
    }
839718
protected function initialize(Request $request, ParamConverter $configuration): void
    {
        $this->request = $request;
        $this->configuration = $configuration;
        $this->options = new ParameterBag($configuration->getOptions());
    }
638571
public function apply(Request $request, ParamConverterConfig $configuration)
    {
        $this->convertClassParamToClassName($configuration);

        return parent::apply($request, $configuration);
    }
8940
protected function includeConfiguration($configuration)
    {
        if (file_exists($configuration)) {
            $callable = include $configuration;
            if (is_callable($callable)) {
                call_user_func($callable, $this->eventEmitter);
            }
        }

        return true;
    }
1052138
public function uploadAction(Request $request, $uploadConfiguration = null)
    {
        $returnData = [];

        if ($request->get('lifetime') !== null) {
            $lifetime = new \DateTime($request->get('lifetime'));
        }

        if (empty($lifetime) || $lifetime == new \DateTime('now')) {
            $lifetime = new \DateTime('+6 hours');
        }

        if ($uploadConfiguration !== null &&
            !array_key_exists($uploadConfiguration, $this->getParameter("alpixel_media.upload_configurations"))
        ) {
            throw new \InvalidArgumentException();
        }

        $mediaPreview = $this->get('twig.extension.media_preview_extension');
        foreach ($request->files as $files) {
            if (!is_array($files)) {
                $files = [$files];
            }
            foreach ($files as $file) {
                /** @var UploadedFile $file */
                try {
                    $media = $this->get('alpixel_media.manager')->upload(
                        $file,
                        $request->get('folder'),
                        $lifetime,
                        $uploadConfiguration
                    );

                    $path = $mediaPreview->generatePathFromSecretKey($media->getSecretKey());
                    $returnData[] = [
                        'id'    => $media->getSecretKey(),
                        'path'  => $path,
                        'name'  => $media->getName(),
                        'error' => false,
                    ];
                } catch (InvalidMimeTypeException $e) {
                    $returnData[] = [
                        'name'         => $file->getClientOriginalName(),
                        'error'        => true,
                        'errorMessage' => $this->get('translator')->trans(
                            "Le format de fichier %format% n'est pas autorisé",
                            [
                                '%format%' => $file->getClientMimeType(),
                            ]
                        ),
                    ];
                }
            }
        }

        return new JsonResponse($returnData);
    }
1220698
private function applyConverter(Request $request, ParamConverter $configuration)
    {
        $value = $request->attributes->get($configuration->getName());
        $className = $configuration->getClass();

        // If the value is already an instance of the class we are trying to convert it into
        // we should continue as no conversion is required
        if (\is_object($value) && $value instanceof $className) {
            return;
        }

        if ($converterName = $configuration->getConverter()) {
            if (!isset($this->namedConverters[$converterName])) {
                throw new \RuntimeException(sprintf(
                    "No converter named '%s' found for conversion of parameter '%s'.",
                    $converterName,
                    $configuration->getName()
                ));
            }

            $converter = $this->namedConverters[$converterName];

            if (!$converter->supports($configuration)) {
                throw new \RuntimeException(sprintf(
                    "Converter '%s' does not support conversion of parameter '%s'.",
                    $converterName,
                    $configuration->getName()
                ));
            }

            $converter->apply($request, $configuration);

            return;
        }

        foreach ($this->all() as $converter) {
            if ($converter->supports($configuration)) {
                if ($converter->apply($request, $configuration)) {
                    return;
                }
            }
        }
    }
931996
private function checkRequestMime(Request $request, $requestMime)
    {
        if(empty($requestMime))
        {
            return true;
        }
        return Imi::checkCompareValues($requestMime, $request->getHeaderLine('Content-Type'));
    }
467846
public function apply(Request $request, ParamConverter $configuration)
    {
        $name = $configuration->getName();
        $class = $configuration->getClass();
        $options = $this->getOptions($configuration);

        if (null === $request->attributes->get($name, false)) {
            $configuration->setIsOptional(true);
        }

        // find by identifier?
        if (false === $object = $this->find($class, $request, $options, $name)) {
            // find by criteria
            if (false === $object = $this->findOneBy($class, $request, $options)) {
                if ($configuration->isOptional()) {
                    $object = null;
                } else {
                    throw new \LogicException(
                        'Unable to guess how to get a Doctrine instance from the request information.'
                    );
                }
            }
        }

        if (null === $object && false === $configuration->isOptional()) {
            throw new NotFoundHttpException(sprintf('%s object not found.', $class));
        }
        $this->reverter->revert($object);
        $request->attributes->set($name, $object);

        return true;
    }