@param \Illuminate\Http\Request $request
@param ModelConfigurationInterface $modelConfiguration

@throws ValidationException
165410
public function validateForm(\Illuminate\Http\Request $request, ModelConfigurationInterface $modelConfiguration = null)
    {
        if (! $this->validModelConfiguration($modelConfiguration)) {
            return;
        }

        $verifier = app('validation.presence');

        $verifier->setConnection($this->getModel()->getConnectionName());

        $validator = \Validator::make(
            $request->all(),
            $this->getValidationRules(),
            $this->getValidationMessages(),
            $this->getValidationLabels()
        );

        $validator->setPresenceVerifier($verifier);

        $this->getModelConfiguration()->fireEvent('validate', false, $this->getModel(), $validator);

        if ($validator->fails()) {
            throw new ValidationException($validator);
        }
    }
1168122
public function deleteAction(Request $request, $id)
    {
        /** @var ConfiguratorFactory $configuratorFactory */
        $configuratorFactory = $this->getConfiguratorFactory($this->getClassName());
        /** @var CrudConfigurator $crudConfigurator */
        $crudConfigurator = $configuratorFactory->getConfigurator(CrudConfigurator::class);

        $this->isGrantedOr404Error($crudConfigurator, Constants::ACTION_DELETE);

        /** @var ModelInterface $model */
        $model = $this->findOr404Error($id);
        /** @var View $view */
        $view = $this->get('symfonyid.admin.view.view');

        $driver = $this->get('symfonyid.admin.manager.driver_finder')->findDriverForClass($crudConfigurator->getCrud()->getModelClass());
        $crudFactory = $this->get('symfonyid.admin.crud.crud_factory');
        $crudFactory->setRequest($request);
        $crudFactory->setDriver($driver);
        $crudFactory->setView($view);

        return $crudFactory->remove($model);
    }
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;
    }
30760
public function apply(Request $request, ParamConverter $configuration)
    {
        $name = $configuration->getName();
        $class = $configuration->getClass();
        $options = $this->getOptions($configuration);

        $reflectionClass = new ReflectionClass($class);
        if (!$reflectionClass->implementsInterface('Ehann\Bundle\WebServiceBundle\Request\IWebServiceRequest')) {
            return false;
        }

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

        $object = $this->find($class, $request, $options, $name);
        if ($object === false && $request->isMethod('GET')) {
            $object = $this->findOneBy($class, $request, $options);
        } else if ($request->isMethod('POST')) {
            $requestObject = new $class;
            $keys = array_keys($request->request->all());
            $options['mapping'] = $keys ? array_combine($keys, $keys) : array();
            $em = $this->getManager($options['entity_manager'], $class);
            $metadata = $em->getClassMetadata($class);

            foreach ($options['mapping'] as $parameter => $field) {
                if ($metadata->hasField($field) || ($metadata->hasAssociation($field) && $metadata->isSingleValuedAssociation($field))) {
                    $methodSuffix = ucfirst($field);
                    $setMethodName = 'set' . $methodSuffix;
                    $value = $request->request->get($parameter);
                    if ('datetime' === $metadata->getTypeOfField($field)) {
                        try {
                            $value = new \DateTime($value);
                        } catch (\Exception $exception) {
                            throw new NotFoundHttpException('Invalid date given.', $exception);
                        }
                    }
                    if (method_exists($requestObject, $setMethodName)) {
                        $requestObject->{$setMethodName}($value);
                    }
                }
            }

            if ($object !== false) {
                // Merge
                foreach ($metadata->getFieldNames() as $fieldName => $fieldType) {
                    $methodSuffix = ucfirst($fieldName);
                    $getMethodName = 'get' . $methodSuffix;
                    $value = $requestObject->{$getMethodName}();
                    if (is_null($value)) {
                        $value = $object->{$getMethodName}();
                    }
                    $setMethodName = 'set' . $methodSuffix;
                    if (method_exists($requestObject, $setMethodName)) {
                        $requestObject->{$setMethodName}($value);
                    }
                }
            }
            $object = $requestObject;
        }

        if ($object === false && !$configuration->isOptional()) {
            throw new NotFoundHttpException(sprintf('%s object not found.', $class));
        }

        $request->attributes->set($name, $object);

        return true;
    }
27562
protected function throwValidationException(Request $request, $validator)
    {
        throw new ResourceException($validator->errors()->first(), $validator->errors());
//        throw new ValidationException($validator, $this->buildFailedValidationResponse(
//            $request, $this->formatValidationErrors($validator)
//        ));
    }
501662
protected function validateRequest(Request $request)
    {
        $validationErrors = array();

        if (strlen($request->getApiMethod()) == 0)
        {
            $validationErrors[] = 'Request api method is empty';
        }

        if (strlen($request->getEndPoint()) == 0 && strlen($request->getEndPointGroup()) === 0)
        {
            $validationErrors[] = 'Request end point is empty and request end point group is empty. Set one of them.';
        }

        if (strlen($request->getEndPoint()) > 0 && strlen($request->getEndPointGroup()) > 0)
        {
            $validationErrors[] = 'Request end point was set and request end point group was set. Set only one of them.';
        }

        if (count($request->getRequestFields()) === 0)
        {
            $validationErrors[] = 'Request data is empty';
        }

        if (!Validator::validateByRule($request->getGatewayUrl(), Validator::URL, false))
        {
            $validationErrors[] = 'Gateway url does not valid in Request';
        }

        if (!empty($validationErrors))
        {
            throw new ValidationException("Some Request fields are invalid:\n" .
                                          implode(";\n", $validationErrors));
        }
    }
1196300
protected function doIndexAction(AbstractAdminListConfigurator $configurator, Request $request)
    {
        $em = $this->getEntityManager();
        /* @var AdminList $adminList */
        $adminList = $this->container->get('kunstmaan_adminlist.factory')->createList($configurator, $em);
        $adminList->bindRequest($request);

        $this->buildSortableFieldActions($configurator);

        return new Response(
            $this->renderView(
                $configurator->getListTemplate(),
                array('adminlist' => $adminList, 'adminlistconfigurator' => $configurator, 'addparams' => array())
            )
        );
    }
85546
public function validate() {
		parent::validate();

		if ($this->getEntity() === null) {
			throw new ValidationException("'entity' can't be null", 'entity', $this);
		}
		if ($this->getEntityStates() === null) {
			throw new ValidationException("'entityStates' can't be null", 'entityStates', $this);
		}
		if ($this->getUrl() === null) {
			throw new ValidationException("'url' can't be null", 'url', $this);
		}
	}
781611
public function apply(Request $request, $configurations)
    {
        if (\is_object($configurations)) {
            $configurations = [$configurations];
        }

        foreach ($configurations as $configuration) {
            $this->applyConverter($request, $configuration);
        }
    }
1082870
public function addConfiguration(ConfigurationInterface $configuration)
    {
        if (isset($this->configurations[$configuration->getName()])) {
            throw new ConfigurationException(sprintf('Configuration "%s" already added.', $configuration->getName()));
        }

        $this->validateConfiguration($configuration);

        $this->configurations[$configuration->getName()] = $configuration;
    }
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;
                }
            }
        }
    }
598784
public function validateValidatorConfiguration($validatorConfiguration)
    {
        $validationErrors = array();
        $validator = new EmailAddressValidator();

        foreach ($validatorConfiguration as $validatorIdentifier => $constraints) {
            if ($validatorIdentifier !== 'EmailAddressValidator') {
                $validationErrors[] = new ValidationError(
                    "Validator '%validator%' is unknown",
                    null,
                    array(
                        '%validator%' => $validatorIdentifier,
                    ),
                    "[$validatorIdentifier]"
                );
                continue;
            }
            $validationErrors += $validator->validateConstraints($constraints);
        }

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

        $options = $configuration->getOptions();

        if ($options['authenticatedUser'] === true) {
            if (($user = $this->tokenStorage->getToken()->getUser()) instanceof User) {
                $request->attributes->set($parameter, $user);

                return true;
            } else {
                if (array_key_exists('messageEnabled', $options) && $options['messageEnabled'] === true) {
                    $messageType = 'warning';
                    if (array_key_exists('messageType', $options)) {
                        $messageType = $options['messageType'];
                    }

                    $messageTranslationKey = 'this_page_requires_authentication';
                    $messageTranslationDomain = 'platform';
                    if (array_key_exists('messageTranslationKey', $options)) {
                        $messageTranslationKey = $options['messageTranslationKey'];
                        if (array_key_exists('messageTranslationDomain', $options)) {
                            $messageTranslationDomain = $options['messageTranslationDomain'];
                        }
                    }

                    $request->getSession()->getFlashBag()->add(
                        $messageType,
                        $this->translator->trans($messageTranslationKey, [], $messageTranslationDomain)
                    );
                }

                throw new AccessDeniedException();
            }
        } else {
            $request->attributes->set($parameter, $user = $this->tokenStorage->getToken()->getUser());
        }
    }
206498
public function apply(Request $request, ParamConverter $configuration)
    {
        if (!$request->attributes->has($this->getPropertyName())) {
            return false;
        }

        $valueObjectId = $request->attributes->get($this->getPropertyName());
        if (!$valueObjectId && $configuration->isOptional()) {
            return false;
        }

        $request->attributes->set($configuration->getName(), $this->loadValueObject($valueObjectId));

        return true;
    }
97474
public function apply(Request $request, ParamConverter $configuration)
    {
        $slug = $request->get('slug', null);
        $username = $request->get('username', null);
        $id = $request->get('id', null);

        if ($slug)
        {
            $searchArray = array('slug' => $slug);
        }
        elseif($username)
        {
            $searchArray = array('username' => $username);
        }
        elseif($id)
        {
            $searchArray = array('id' => $id);
        }
        else
        {
            throw new \InvalidArgumentException('Route attribute is missing');
        }

        $class = $this->targetEntitiesArray[$configuration->getClass()];

        $repository = $this->doctrine->getRepository($class);

        $object = $repository->findOneBy( $searchArray );

        if(!$object)
            throw new NotFoundHttpException("Sorry, requested resource can't be found.");

        $request->attributes->set($configuration->getName(), $object);

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

        // Check whether we need to let pass anonymous
        $allowAnonymous = false;
        $options = $configuration->getOptions();
        if ($options && isset($options['allowAnonymous']) && true === $options['allowAnonymous']) {
            $allowAnonymous = true;
        }

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

                return true;
            } elseif ($allowAnonymous) {
                $request->attributes->set($parameter, null);

                return true;
            }
        }

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

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

        return true;
    }