Some of them are applicable to the constructor, other are applicable to other handlers. For the latter you need to make sure there is a handler defined for that option
Author: Raphael Antonmattei (rantonmattei@theorchard.com)
Author: Dom Morgan (dom@d3r.com)
コード例 #1
0
 /**
  * Constructor
  * @see ClassLoader::__construct
  * @see Monolog\Handler classes for handler options
  *
  * @param array $handlerOptions Handler options
  * @param Monolog\Formatter\FormatterInterface[] $formatters Array of formatter to pick from
  * @param callable[] $processors Array of processors to pick from
  */
 public function __construct(array &$handlerOptions, array $formatters = array(), array $processors = array())
 {
     $this->populateFormatters($handlerOptions, $formatters);
     $this->populateProcessors($handlerOptions, $processors);
     parent::__construct($handlerOptions);
     self::initExtraOptionsHandlers();
 }
コード例 #2
0
 public function testLoad()
 {
     $options = array('class' => 'Cascade\\Tests\\Fixtures\\SampleClass', 'mandatory' => 'someValue', 'optional_X' => 'testing some stuff', 'optional_Y' => 'testing other stuff', 'hello' => 'hello', 'there' => 'there');
     ClassLoader::$extraOptionHandlers = array('*' => array('hello' => function ($instance, $value) {
         $instance->setHello(strtoupper($value));
     }), 'Cascade\\Tests\\Fixtures\\SampleClass' => array('there' => function ($instance, $value) {
         $instance->setThere(strtoupper($value) . '!!!');
     }));
     $loader = new ClassLoader($options);
     $instance = $loader->load();
     $expectedInstance = new SampleClass('someValue');
     $expectedInstance->optionalX('testing some stuff');
     $expectedInstance->optionalY = 'testing other stuff';
     $expectedInstance->setHello('HELLO');
     $expectedInstance->setThere('THERE!!!');
     $this->assertEquals($expectedInstance, $instance);
 }
コード例 #3
0
 /**
  * Constructor
  * @see ClassLoader::__construct
  * @see Monolog\Formatter classes for formatter options
  *
  * @param array $formatterOptions Formatter options
  */
 public function __construct(array $formatterOptions)
 {
     parent::__construct($formatterOptions);
     self::initExtraOptionsHandlers();
 }
コード例 #4
0
 /**
  * Test a nested class to load
  */
 public function testLoadDependency()
 {
     $options = array('class' => 'Cascade\\Tests\\Fixtures\\DependentClass', 'dependency' => array('class' => 'Cascade\\Tests\\Fixtures\\SampleClass', 'mandatory' => 'someValue'));
     $loader = new ClassLoader($options);
     $instance = $loader->load();
     $expectedInstance = new DependentClass(new SampleClass('someValue'));
     $this->assertEquals($expectedInstance, $instance);
 }
コード例 #5
0
 /**
  * Constructor
  * @see ClassLoader::__construct
  * @see Monolog\Handler classes for handler options
  *
  * @param array $processorOptions Processor options
  * @param Monolog\Processor\ProcessorInterface[] $processors Array of processors to pick from
  */
 public function __construct(array &$processorOptions, array $processors = array())
 {
     parent::__construct($processorOptions);
     // @todo add additional options later?  Is the "tags" option needed in this implementation?
 }
コード例 #6
0
 /**
  * Recursively loads objects into any of the rawOptions that represent
  * a class
  */
 protected function loadChildClasses()
 {
     foreach ($this->rawOptions as &$option) {
         if (is_array($option) && array_key_exists('class', $option) && class_exists($option['class'])) {
             $classLoader = new ClassLoader($option);
             $option = $classLoader->load();
         }
     }
 }