Exemple #1
0
 /**
  * {@inheritdoc}
  */
 public function get($typeName, InjectionPointInterface $point = NULL)
 {
     if ($typeName === Configuration::class) {
         if ($point === NULL) {
             return $this->config;
         }
         return $this->config->getConfig(str_replace('\\', '.', $point->getTypeName()));
     }
     if (isset($this->proxies[$typeName])) {
         return $this->proxies[$typeName];
     }
     if (isset($this->bindings[$typeName])) {
         return $this->getBound($this->bindings[$typeName], $point);
     }
     return $this->createObject($typeName);
 }
Exemple #2
0
 /**
  * Obtain a logger instance, the log channel will consist of the type name provided by the injection point
  * where all namespace separators will be replaced by periods.
  * 
  * @param ExposedContainerInterface $container DI container being used for log handler creation.
  * @param InjectionPointInterface $point The target of the injection.
  * @return LoggerInterface Created (or cached) logger instance.
  */
 public function getLogger(ExposedContainerInterface $container, InjectionPointInterface $point = NULL)
 {
     $channel = $point === NULL ? 'app' : str_replace('\\', '.', $point->getTypeName());
     if (isset($this->loggers[$channel])) {
         return $this->loggers[$channel];
     }
     $logger = new Logger($channel);
     $logger->pushProcessor(new PsrLogMessageProcessor());
     $handled = false;
     foreach ($this->matchers as $handlerName => $patterns) {
         foreach ($patterns as $pattern) {
             if (preg_match($pattern, $channel)) {
                 $logger->pushHandler($this->getHandler($handlerName, $container));
                 $handled = true;
                 break;
             }
         }
     }
     if (!$handled) {
         $logger->pushHandler(new NullHandler());
     }
     return $this->loggers[$channel] = $logger;
 }