/**
  * Gets the logger for a specific channel.
  *
  * @param string $channel
  *   The name of the channel.
  *
  * @return \Psr\Log\LoggerInterface
  *   The logger for this channel
  */
 protected function logger($channel)
 {
     if (!$this->loggerFactory) {
         $this->loggerFactory = \Drupal::service('logger.factory');
     }
     return $this->loggerFactory->get($channel);
 }
 /**
  * Constructor for MetatagManager.
  *
  * @param MetatagGroupPluginManager $groupPluginManager
  * @param MetatagTagPluginManager $tagPluginManager
  * @param MetatagToken $token
  */
 public function __construct(MetatagGroupPluginManager $groupPluginManager, MetatagTagPluginManager $tagPluginManager, MetatagToken $token, LoggerChannelFactory $channelFactory)
 {
     $this->groupPluginManager = $groupPluginManager;
     $this->tagPluginManager = $tagPluginManager;
     $this->tokenService = $token;
     $this->logger = $channelFactory->get('metatag');
 }
 /**
  * Tests LoggerChannelFactory::get().
  *
  * @covers ::get
  */
 public function testGet()
 {
     $factory = new LoggerChannelFactory();
     $factory->setContainer($this->getMock('Symfony\\Component\\DependencyInjection\\ContainerInterface'));
     // Ensure that when called with the same argument, always the same instance
     // will be returned.
     $this->assertSame($factory->get('test'), $factory->get('test'));
 }
Beispiel #4
0
 /**
  * {@inheritdoc}
  */
 protected function setUp()
 {
     parent::setUp();
     $this->urlGenerator = $this->getMock('\\Drupal\\Core\\Routing\\UrlGeneratorInterface');
     $this->connection = $this->getMockBuilder('\\Drupal\\Core\\Database\\Connection')->disableOriginalConstructor()->getMock();
     $this->loggerFactory = $this->getMock('\\Drupal\\Core\\Logger\\LoggerChannelFactory');
     $this->loggerChannel = $this->getMockBuilder('\\Drupal\\Core\\Logger\\LoggerChannel')->disableOriginalConstructor()->getMock();
     $this->loggerFactory->expects($this->any())->method('get')->with('cas')->will($this->returnValue($this->loggerChannel));
 }
Beispiel #5
0
 /**
  * {@inheritdoc}
  */
 protected function setUp()
 {
     parent::setUp();
     $this->urlGenerator = $this->getMock('\\Drupal\\Core\\Routing\\UrlGeneratorInterface');
     $this->connection = $this->getMockBuilder('\\Drupal\\Core\\Database\\Connection')->disableOriginalConstructor()->getMock();
     $this->loggerFactory = $this->getMock('\\Drupal\\Core\\Logger\\LoggerChannelFactory');
     $this->loggerChannel = $this->getMockBuilder('\\Drupal\\Core\\Logger\\LoggerChannel')->disableOriginalConstructor()->getMock();
     $this->loggerFactory->expects($this->any())->method('get')->with('cas')->will($this->returnValue($this->loggerChannel));
     $storage = $this->getMockBuilder('\\Symfony\\Component\\HttpFoundation\\Session\\Storage\\MockArraySessionStorage')->setMethods(NULL)->getMock();
     $this->session = $this->getMockBuilder('\\Symfony\\Component\\HttpFoundation\\Session\\Session')->setConstructorArgs(array($storage))->setMethods(NULL)->getMock();
     $this->session->start();
 }
Beispiel #6
0
 /**
  * Constructor.
  *
  * @param ConfigFactoryInterface $config_factory
  *   The configuration factory.
  * @param UrlGeneratorInterface $url_generator
  *   The URL generator.
  * @param Connection $database_connection
  *   The database service.
  * @param LoggerChannelFactory $logger_factory
  *   The logger channel factory.
  */
 public function __construct(ConfigFactoryInterface $config_factory, UrlGeneratorInterface $url_generator, Connection $database_connection, LoggerChannelFactory $logger_factory)
 {
     $this->urlGenerator = $url_generator;
     $this->connection = $database_connection;
     $this->settings = $config_factory->get('cas.settings');
     $this->loggerChannel = $logger_factory->get('cas');
 }