* * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Silex; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpKernel\Controller\ArgumentValueResolverInterface; use Symfony\Component\HttpKernel\ControllerMetadata\ArgumentMetadata; /** * HttpKernel Argument Resolver for Silex. * * @author Romain Neutron */ class AppArgumentValueResolver implements ArgumentValueResolverInterface { private $app; public function __construct(Application $app) { $this->app = $app; } /** * {@inheritdoc} */ public function supports(Request $request, ArgumentMetadata $argument) : bool { return null !== $argument->getType() && (Application::class === $argument->getType() || is_subclass_of($argument->getType(), Application::class)); } /** * {@inheritdoc} */ public function resolve(Request $request, ArgumentMetadata $argument) : iterable { yield $this->app; } }