Request/ParamConverter/ServiceParamConverter.php
public function apply(Request $request, ParamConverter $configuration)
    {
        $object = $this->callService($request, $configuration);

        $class = $configuration->getClass();
        if ($object instanceof $class) {
            $request->attributes->set($configuration->getName(), $object);

            return true;
        }

        if ($configuration->isOptional()) {
            return false;
        }

        throw new NotFoundHttpException(sprintf('Object of class "%s" not found.', $class));
    }
public function apply(Request $request, ParamConverter $configuration)
    {
        $object = $this->callService($request, $configuration);

        $class = $configuration->getClass();
        if ($object instanceof $class) {
            $request->attributes->set($configuration->getName(), $object);

            return true;
        }

        if ($configuration->isOptional()) {
            return false;
        }

        throw new NotFoundHttpException(sprintf('Object of class "%s" not found.', $class));
    }
@param Request        $request
@param ParamConverter $configuration

@return bool