-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[FrameworkBundle] Allow to pass a logger instance to the Router #24826
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,6 +11,7 @@ | |
|
||
namespace Symfony\Bundle\FrameworkBundle\Routing; | ||
|
||
use Psr\Log\LoggerInterface; | ||
use Symfony\Component\Config\Loader\LoaderInterface; | ||
use Symfony\Component\DependencyInjection\Config\ContainerParametersResource; | ||
use Symfony\Component\DependencyInjection\ServiceSubscriberInterface; | ||
|
@@ -33,17 +34,19 @@ class Router extends BaseRouter implements WarmableInterface, ServiceSubscriberI | |
private $collectedParameters = array(); | ||
|
||
/** | ||
* @param ContainerInterface $container A ContainerInterface instance | ||
* @param mixed $resource The main resource to load | ||
* @param array $options An array of options | ||
* @param RequestContext $context The context | ||
* @param ContainerInterface $container A ContainerInterface instance | ||
* @param mixed $resource The main resource to load | ||
* @param array $options An array of options | ||
* @param RequestContext $context The context | ||
* @param LoggerInterface|null $logger | ||
*/ | ||
public function __construct(ContainerInterface $container, $resource, array $options = array(), RequestContext $context = null) | ||
public function __construct(ContainerInterface $container, $resource, array $options = array(), RequestContext $context = null, LoggerInterface $logger = null) | ||
{ | ||
$this->container = $container; | ||
|
||
$this->resource = $resource; | ||
$this->context = $context ?: new RequestContext(); | ||
$this->logger = $logger; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just wondering: Why don't we call the parent class' constructor? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks, I missed that. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We should probably change this in 4.1 to have a lazy-loading implementation of the LoaderInterface (using composition over the actual loader which would get loaded when needed), to avoid having a special constructor. |
||
$this->setOptions($options); | ||
} | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
how about using a nullable typehint ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We reverted it last time we tried adding one 😄
See discussion starting from #22743 (comment)