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;
                }
            }
        }
    }
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;
                }
            }
        }
    }
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 ; } } } }
Applies converter on request based on the given configuration.
Applies converter on request based on the given configuration .