@param Request                       $request
@param array|ParamConverterInterface $configuration

@throws \Exception

@return mixed
502587
protected function getDataFromRequest(Request $request, $configuration = null)
    {
        if (null === $configuration) {
            $configuration = [
                new ParamConverter(
                    [
                        'name' => 'data',
                        'class' => $this->admin->getEntity(),
                    ]
                ),
            ];
        }
        $this->container->get('sensio_framework_extra.converter.manager')->apply($request, $configuration);

        return $request->attributes->get('data');
    }
14609
public function execute($request)
    {
        $result = $request->authHeaders()->send();

        if ($result->status === self::API_STATUS_FAIL) {
            throw new Exception('Error: '.$result->error);
        }

        return $result;
    }
253526
protected function prepareObject(Configuration $configuration, Parameter $parameter)
  {
    $this->dispatcher->dispatch(
      TransformerEvents::PREPARE_OBJECT,
      new TransformerEvent($configuration, $parameter)
    );

    $value = $this->build(
      $configuration->getOptions()->getReturnClass(),
      $configuration->getChildren(),
      $this->converter->convertTo($parameter->getValue(), 'array')
    );
    $parameter->setValue($value);

    return $this;
  }
890739
public function apply(Request $request, ParamConverterConfiguration $configuration)
    {
        $name = $configuration->getName();

        $object = $this->manager->getCurrentModule();
        $request->attributes->set($name, $object);

        return true;
    }
1180300
public function create($model, Request $request)
    {
        $settings = json_decode($request->controller_settings);
        $fields = json_decode($request->fields, true);

        //dd($request->all());

        $path = $this->getpath($this->name);

        if ($this->files->exists($path)) {
            throw new \Exception("Controller [$this->name] already exists!");
        }

        $stub = $this->files->get($this->getStub());

        $stub = $this->replace($stub, $this->name, $model)
                        ->replaceDisableds($stub, $settings)
                        ->replaceTimestamps($stub, $settings)
                        ->replaceGrid($stub, $fields)
                        ->replaceForm($stub, $fields)
                        ->replaceHeader($stub, $settings);

        //dd($settings, $stub);

        $this->createMenu($settings);

        $this->createRout($settings);

        $this->files->put($path, $stub);

        return $path;
    }
610988
private function getViolationFilter(Configuration $configuration)
    {
        $violationFilters = array();
        if ('' !== $configuration->filteredMethodCalls()) {
            $violationFilters[] = MethodViolationFilter::fromString($configuration->filteredMethodCalls());
        }

        return new ComposedViolationFilter($violationFilters);
    }
564473
private function validateConfiguration(ConfigurationInterface $configuration)
    {
        $parameterNames = [];

        foreach ($configuration->getModel() as $parameterModel) {
            $parameterName = $parameterModel->getName();
            $parameterType = $parameterModel->getType();
            $parameterDefaultValue = $parameterModel->getDefaultValue();
            $parameterDataType = $parameterModel->getDataType();

            if (null !== $parameterDefaultValue && gettype($parameterDefaultValue) !== $parameterDataType) {
                $message = sprintf(
                    'Parameter "%s" of configuration "%s" must have default value of "%s" type, "%s" type value provided.',
                    $parameterName,
                    $configuration->getName(),
                    $parameterDataType,
                    gettype($parameterDefaultValue)
                );

                throw new ConfigurationException($message);
            }
            if (!ParameterModel::isTypeExists($parameterType)) {
                $message = sprintf(
                    'Type "%s" of "%s" configuration parameter "%s" is not supported. Supported types: "%s".',
                    $parameterType,
                    $configuration->getName(),
                    $parameterName,
                    implode('", "', ParameterModel::getTypes())
                );

                throw new ConfigurationException($message);
            }
            if (in_array($parameterName, $parameterNames)) {
                $message = sprintf(
                    'Parameter "%s" of configuration "%s" already defined.',
                    $parameterName,
                    $configuration->getName()
                );

                throw new ConfigurationException($message);
            }

            $parameterNames[] = $parameterName;
        }
    }
736456
protected function prepareValue(Configuration $configuration, Parameter $parameter)
  {
    $this->dispatcher->dispatch(
      TransformerEvents::PREPARE_VALUE,
      new TransformerEvent($configuration, $parameter)
    );

    switch ($configuration->getType())
    {
      case TypeEnum::COLLECTION_TYPE:
        $this->prepareCollection($configuration, $parameter);
        break;
      case TypeEnum::OBJECT_TYPE:
        $this->prepareObject($configuration, $parameter);
        break;
      case TypeEnum::DATE_TYPE:
        $this->prepareDate($configuration, $parameter);
        break;
      case TypeEnum::INDIVIDUAL_TYPE:
        $this->prepareIndividual($configuration, $parameter);
        break;
      case TypeEnum::ARRAY_TYPE:
        $this->prepareArray($configuration, $parameter);
        break;
    }

    return $this;
  }
705756
public function run(Config $configuration)
    {
        $this->config = $configuration;
        $this->config->set('base', str_replace('app.php', '', $_SERVER['SCRIPT_NAME']));
        try {
            $request = $this->getRequest();
            if (!$this->config->get('routes')) {
                throw new Exception404( "No routes", 1 );
            } else {
                list($controller_name, $action_name, $parameters) = $this->findRoute($request);
            }

            $controller = new $controller_name();
            $controller->$action_name( $parameters );
        } catch ( Exception404 $e ) {
            $e->displayMessage();
        }
    }
1245190
public function viewAction(Request $request): Response
    {
        $configuration = $this->requestConfigurationFactory->create($this->metadata, $request);

        $this->isGrantedOr403($configuration, ResourceActions::SHOW);

        /** @var DefinedTranslationInterface|TemplateAwareInterface|ResourceInterface $resource */
        $resource = $this->findOr404($configuration);

        $this->eventDispatcher->dispatch(ResourceActions::SHOW, $configuration, $resource);

        $view = View::create($resource);

        if ($configuration->isHtmlRequest()) {
            $template = $resource->getTemplate();

            if ($template) {
                $tpl = $resource->getTemplateName();
                $options = $template->getOptions();
            } else {
                $tpl = $configuration->getTemplate(ResourceActions::SHOW.'.html');
                $options = [];
            }

            $this->addTranslations($resource);

            $view
                ->setTemplate($tpl)
                ->setTemplateVar($this->metadata->getName())
                ->setData(
                    [
                        'configuration' => $configuration,
                        'metadata' => $this->metadata,
                        'resource' => $resource,
                        'tpl' => ['options' => $options],
                        $this->metadata->getName() => $resource,
                    ]
                );
        }

        return $this->viewHandler->handle($configuration, $view);
    }
357329
public function apply(Request $request, ParamConverter $configuration)
    {
        $param = $configuration->getName();

        if (!$request->attributes->has($param)) {
            return false;
        }

        $options = $configuration->getOptions();
        $value = $request->attributes->get($param);

        if (!$value && $configuration->isOptional()) {
            $request->attributes->set($param, null);

            return true;
        }

        $class = $configuration->getClass();

        if (isset($options['format'])) {
            $date = $class::createFromFormat($options['format'], $value);

            if (0 < DateTime::getLastErrors()['warning_count']) {
                $date = false;
            }

            if (!$date) {
                throw new NotFoundHttpException(sprintf('Invalid date given for parameter "%s".', $param));
            }
        } else {
            if (false === strtotime($value)) {
                throw new NotFoundHttpException(sprintf('Invalid date given for parameter "%s".', $param));
            }

            $date = new $class($value);
        }

        $request->attributes->set($param, $date);

        return true;
    }
908010
protected function execute(array $configuration, &$context)
    {
        $parameters = $this->confHelper->resolve($configuration[self::CONF_PARAMETERS], $context);
        $parameters = $this->prepareParameters($parameters);

        $sql = $this->confHelper->resolve($configuration[self::CONF_SQL], $context);

        return $this->performQuery($configuration, $context, $parameters, $sql);
    }
603765
public function retrieveCurrent(Request $request)
    {
        if (ConfigQuery::isRewritingEnable()) {
            $view = $request->attributes->get('_view', null);

            $viewLocale = $this->getViewLocale($request);

            $viewId = $view === null ? null : $request->query->get($view . '_id', null);

            $allOtherParameters = $request->query->all();
            if ($view !== null) {
                unset($allOtherParameters['view']);
                if ($viewId !== null) {
                    unset($allOtherParameters[$view . '_id']);
                }
            }
            if ($viewLocale !== null) {
                unset($allOtherParameters['lang']);
                unset($allOtherParameters['locale']);
            }

            $this->retriever->loadSpecificUrl($view, $viewLocale, $viewId, $allOtherParameters);
        } else {
            $allParametersWithoutView = $request->query->all();
            $view = $request->attributes->get('_view');
            if (isset($allOtherParameters['view'])) {
                unset($allOtherParameters['view']);
            }
            $this->retriever->rewrittenUrl = null;
            $this->retriever->url = URL::getInstance()->viewUrl($view, $allParametersWithoutView);
        }

        return $this->retriever;
    }
1243196
private function getViolationDetector(Configuration $configuration)
    {
        $violationChecker = $this->getViolationChecker($configuration);
        $violationFilter = $this->getViolationFilter($configuration);

        return new ViolationDetector(
            $violationChecker,
            $violationFilter
        );
    }
1241857
public function write($configuration)
    {
        $ht = $this->getHTaccessFilename();
        $fs = $this->getFilesystem();
        if (@$fs->put($ht, $configuration) === false) {
            throw new Exception("Failed to write to file $ht");
        }
    }
1202005
public function execute(Request $request)
    {
        $command = $request->get('command');

        try {
            $result = $this->manager()->execute($command);
        } catch (\Exception $exception) {
            return $this->renderException($exception);
        }

        if (is_string($result) && Str::startsWith($result, ['ERR ', 'WRONGTYPE '])) {
            return $this->renderException(new \Exception($result));
        }

        return $this->getDumpedHtml($result);
    }
1342111
public function getConfiguration(Request $request): JsonResponse
    {
        $domain = $request->query->get('domain');

        if (!$domain) {
            throw new MissingRequestParameterException('domain');
        }

        return new JsonResponse($this->configurationService->getConfiguration($domain));
    }