src/Handler/Parameter/ObjectMapperParameterResolverAndExtractor.php
private function resolveRequest(
        ActionInterface $action,
        CallableInterface $callable,
        array $inputArguments,
        \ReflectionParameter $parameter
    ) {
        $class = $parameter->getClass();

        if ($class->isInterface()) {
            throw new \RuntimeException(sprintf(
                'Could not create instance via interface for parameter "%s" in method "%s". ' .
                'You must set the class for type hinting.',
                $parameter->getName(),
                Reflection::getCalledMethod($callable->getReflection())
            ));
        }

        if ($class->isAbstract()) {
            throw new \RuntimeException(sprintf(
                'Could not create instance via abstract class for parameter "%s" in method "%s". ' .
                'You must set the real class for type hinting.',
                $parameter->getName(),
                Reflection::getCalledMethod($callable->getReflection())
            ));
        }

        /** @var RequestInterface $request */
        $request = $class->newInstance();

        // Map arguments
        $this->objectMapper->map($request, $inputArguments, $action->getRequestMappingGroup());

        // First step validation: Strict mode
        if ($this->validator && $action->isStrictValidation()) {
            $this->strictRequestValidate($request);
        }

        // Second step validation: Base validation
        if ($this->validator && $action->getValidationGroups()) {
            $violationList = $this->validator->validate($request, null, $action->getValidationGroups());

            if (count($violationList)) {
                throw ViolationListException::create($violationList);
            }
        }

        // Convert request properties
        if ($this->propertyConverter) {
            try {
                $this->propertyConverter->convertProperties(
                    $request,
                    PropertyConverterManagerInterface::GROUP_DEFAULT
                );
            } catch (InvalidArgumentException $e) {
                $constraintViolation = new ConstraintViolation(
                    $e->getMessage(),
                    null,
                    [],
                    null,
                    $e->getName(),
                    $e->getInvalidValue()
                );

                $constraintViolationList = new ConstraintViolationList([$constraintViolation]);

                throw ViolationListException::create($constraintViolationList);
            } catch (ConverterNotFoundException $e) {
                if ($this->logger) {
                    $this->logger->warning(sprintf(
                        'Could not convert properties with message: %s.',
                        rtrim($e->getMessage(), '.')
                    ));
                }

                // Nothing action
            }
        }

        return $request;
    }
private function resolveRequest(
        ActionInterface $action,
        CallableInterface $callable,
        array $inputArguments,
        \ReflectionParameter $parameter
    ) {
        $class = $parameter->getClass();

        if ($class->isInterface()) {
            throw new \RuntimeException(sprintf(
                'Could not create instance via interface for parameter "%s" in method "%s". ' .
                'You must set the class for type hinting.',
                $parameter->getName(),
                Reflection::getCalledMethod($callable->getReflection())
            ));
        }

        if ($class->isAbstract()) {
            throw new \RuntimeException(sprintf(
                'Could not create instance via abstract class for parameter "%s" in method "%s". ' .
                'You must set the real class for type hinting.',
                $parameter->getName(),
                Reflection::getCalledMethod($callable->getReflection())
            ));
        }

        /** @var RequestInterface $request */
        $request = $class->newInstance();

        // Map arguments
        $this->objectMapper->map($request, $inputArguments, $action->getRequestMappingGroup());

        // First step validation: Strict mode
        if ($this->validator && $action->isStrictValidation()) {
            $this->strictRequestValidate($request);
        }

        // Second step validation: Base validation
        if ($this->validator && $action->getValidationGroups()) {
            $violationList = $this->validator->validate($request, null, $action->getValidationGroups());

            if (count($violationList)) {
                throw ViolationListException::create($violationList);
            }
        }

        // Convert request properties
        if ($this->propertyConverter) {
            try {
                $this->propertyConverter->convertProperties(
                    $request,
                    PropertyConverterManagerInterface::GROUP_DEFAULT
                );
            } catch (InvalidArgumentException $e) {
                $constraintViolation = new ConstraintViolation(
                    $e->getMessage(),
                    null,
                    [],
                    null,
                    $e->getName(),
                    $e->getInvalidValue()
                );

                $constraintViolationList = new ConstraintViolationList([$constraintViolation]);

                throw ViolationListException::create($constraintViolationList);
            } catch (ConverterNotFoundException $e) {
                if ($this->logger) {
                    $this->logger->warning(sprintf(
                        'Could not convert properties with message: %s.',
                        rtrim($e->getMessage(), '.')
                    ));
                }

                // Nothing action
            }
        }

        return $request;
    }
private function resolveRequest ( ActionInterface $ action , CallableInterface $ callable , array $ inputArguments , \ ReflectionParameter $ parameter ) { $ class = $ parameter -> getClass ( ) ; if ( $ class -> isInterface ( ) ) { throw new \ RuntimeException ( sprintf ( 'Could not create instance via interface for parameter "%s" in method "%s". ' . 'You must set the class for type hinting.' , $ parameter -> getName ( ) , Reflection :: getCalledMethod ( $ callable -> getReflection ( ) ) ) ) ; } if ( $ class -> isAbstract ( ) ) { throw new \ RuntimeException ( sprintf ( 'Could not create instance via abstract class for parameter "%s" in method "%s". ' . 'You must set the real class for type hinting.' , $ parameter -> getName ( ) , Reflection :: getCalledMethod ( $ callable -> getReflection ( ) ) ) ) ; } /** @var RequestInterface $request */ $ request = $ class -> newInstance ( ) ; // Map arguments $ this -> objectMapper -> map ( $ request , $ inputArguments , $ action -> getRequestMappingGroup ( ) ) ; // First step validation: Strict mode if ( $ this -> validator && $ action -> isStrictValidation ( ) ) { $ this -> strictRequestValidate ( $ request ) ; } // Second step validation: Base validation if ( $ this -> validator && $ action -> getValidationGroups ( ) ) { $ violationList = $ this -> validator -> validate ( $ request , null , $ action -> getValidationGroups ( ) ) ; if ( count ( $ violationList ) ) { throw ViolationListException :: create ( $ violationList ) ; } } // Convert request properties if ( $ this -> propertyConverter ) { try { $ this -> propertyConverter -> convertProperties ( $ request , PropertyConverterManagerInterface :: GROUP_DEFAULT ) ; } catch ( InvalidArgumentException $ e ) { $ constraintViolation = new ConstraintViolation ( $ e -> getMessage ( ) , null , [ ] , null , $ e -> getName ( ) , $ e -> getInvalidValue ( ) ) ; $ constraintViolationList = new ConstraintViolationList ( [ $ constraintViolation ] ) ; throw ViolationListException :: create ( $ constraintViolationList ) ; } catch ( ConverterNotFoundException $ e ) { if ( $ this -> logger ) { $ this -> logger -> warning ( sprintf ( 'Could not convert properties with message: %s.' , rtrim ( $ e -> getMessage ( ) , '.' ) ) ) ; } // Nothing action } } return $ request ; }
Resolve request parameter

@param ActionInterface      $action
@param CallableInterface    $callable
@param array                $inputArguments
@param \ReflectionParameter $parameter

@return object

@throws \Exception
Resolve request parameter