public function LoggerChannelFactory::get in TMGMT Translator Smartling 8.4
Same name and namespace in other branches
- 8.3 modules/tmgmt_smartling_log_settings/src/Logger/LoggerChannelFactory.php \Drupal\tmgmt_smartling_log_settings\Logger\LoggerChannelFactory::get()
Retrieves the registered logger for the requested channel.
Return value
\Drupal\Core\Logger\LoggerChannelInterface The registered logger for this channel.
Overrides LoggerChannelFactory::get
File
- modules/
tmgmt_smartling_log_settings/ src/ Logger/ LoggerChannelFactory.php, line 15
Class
- LoggerChannelFactory
- Defines a factory for logging channels.
Namespace
Drupal\tmgmt_smartling_log_settings\LoggerCode
public function get($channel) {
if (!isset($this->channels[$channel])) {
// Same as core's LoggerChannelFactory but we instantiate
// Drupal\tmgmt_smartling_log_settings\Logger\LoggerChannel instead
// of Drupal\Core\Logger\LoggerChannelFactory.
$instance = new LoggerChannel($channel);
// If we have a container set the request_stack and current_user services
// on the channel. It is up to the channel to determine if there is a
// current request.
if ($this->container) {
$instance
->setRequestStack($this->container
->get('request_stack'));
$instance
->setCurrentUser($this->container
->get('current_user'));
}
// Pass the loggers to the channel.
$instance
->setLoggers($this->loggers);
$this->channels[$channel] = $instance;
}
return $this->channels[$channel];
}