Exemplo n.º 1
0
 /**
  * Constructor.
  * The default implementation does two things:
  *
  * - Initializes the object with the given configuration `$config`.
  * - Call [[init()]].
  *
  * If this method is overridden in a child class, it is recommended that
  *
  * - the last parameter of the constructor is a configuration array, like `$config` here.
  * - call the parent implementation at the end of the constructor.
  *
  * @param array $config name-value pairs that will be used to initialize the object properties
  */
 public function __construct($config = [])
 {
     if (!empty($config)) {
         Creator::configure($this, $config);
     }
     $this->init();
 }
Exemplo n.º 2
0
 protected function configure($config = [])
 {
     if (!empty($config)) {
         $autoCamelCase = isset($this->autoCamelCase) ? $this->autoCamelCase : false;
         Creator::configure($this, $config, $autoCamelCase);
     }
 }
Exemplo n.º 3
0
 public function testConfigure()
 {
     $obj = Creator::createObject(['class' => 'TestCreate', 'test' => 1]);
     $this->assertInstanceOf('TestCreate', $obj);
     $this->assertEquals(1, $obj->test);
     Creator::configure($obj, ['test' => 2]);
     $this->assertEquals(2, $obj->test);
 }
 public function __construct(Model $model, array $config = [])
 {
     Creator::configure($this, $config);
     $this->_model = $model;
 }
Exemplo n.º 5
0
 protected function configure($config = [])
 {
     if (!empty($config)) {
         Creator::configure($this, $config);
     }
 }