2015-08-17 17:00:26 -07:00
< ? php
/*
* This file is part of the Symfony package .
*
* ( c ) Fabien Potencier < fabien @ symfony . com >
*
* For the full copyright and license information , please view the LICENSE
* file that was distributed with this source code .
*/
namespace Symfony\Component\HttpKernel\Controller ;
use Symfony\Component\HttpFoundation\Request ;
2018-11-23 12:29:20 +00:00
use Symfony\Component\Stopwatch\Stopwatch ;
2015-08-17 17:00:26 -07:00
/**
* @ author Fabien Potencier < fabien @ symfony . com >
*/
2018-11-23 12:29:20 +00:00
class TraceableControllerResolver implements ControllerResolverInterface , ArgumentResolverInterface
2015-08-17 17:00:26 -07:00
{
private $resolver ;
private $stopwatch ;
2018-11-23 12:29:20 +00:00
private $argumentResolver ;
2015-08-17 17:00:26 -07:00
2018-11-23 12:29:20 +00:00
public function __construct ( ControllerResolverInterface $resolver , Stopwatch $stopwatch , ArgumentResolverInterface $argumentResolver = null )
2015-08-17 17:00:26 -07:00
{
$this -> resolver = $resolver ;
$this -> stopwatch = $stopwatch ;
2018-11-23 12:29:20 +00:00
$this -> argumentResolver = $argumentResolver ;
// BC
if ( null === $this -> argumentResolver ) {
$this -> argumentResolver = $resolver ;
}
if ( ! $this -> argumentResolver instanceof TraceableArgumentResolver ) {
$this -> argumentResolver = new TraceableArgumentResolver ( $this -> argumentResolver , $this -> stopwatch );
}
2015-08-17 17:00:26 -07:00
}
/**
* { @ inheritdoc }
*/
public function getController ( Request $request )
{
$e = $this -> stopwatch -> start ( 'controller.get_callable' );
$ret = $this -> resolver -> getController ( $request );
$e -> stop ();
return $ret ;
}
/**
* { @ inheritdoc }
2018-11-23 12:29:20 +00:00
*
* @ deprecated This method is deprecated as of 3.1 and will be removed in 4.0 .
2015-08-17 17:00:26 -07:00
*/
public function getArguments ( Request $request , $controller )
{
2018-11-23 12:29:20 +00:00
@ trigger_error ( sprintf ( 'The "%s()" method is deprecated as of 3.1 and will be removed in 4.0. Please use the %s instead.' , __METHOD__ , TraceableArgumentResolver :: class ), E_USER_DEPRECATED );
2015-08-17 17:00:26 -07:00
2018-11-23 12:29:20 +00:00
$ret = $this -> argumentResolver -> getArguments ( $request , $controller );
2015-08-17 17:00:26 -07:00
return $ret ;
}
}