init() public method

Initializes the module.
public init ( ) : void
return void
 /**
  * Initialize the queue.
  */
 public function init()
 {
     parent::init();
     $queueObjects = [];
     foreach ($this->queues as $id => $queue) {
         $queueObjects[$id] = \Yii::createObject($queue);
     }
     $this->queues = $queueObjects;
     if (!isset($this->strategy)) {
         $this->strategy = ['class' => Strategies\RandomStrategy::class];
     }
     $this->strategy = \Yii::createObject($this->strategy);
     $this->strategy->setQueue($this);
 }
Beispiel #2
0
 /**
  * Initialize the queue.
  * @return void
  * @throws \yii\base\InvalidConfigException If the strategy doesn't implement
  * UrbanIndo\Yii2\Queue\Strategies\Strategy.
  */
 public function init()
 {
     parent::init();
     $queueObjects = [];
     foreach ($this->queues as $id => $queue) {
         $queueObjects[$id] = \Yii::createObject($queue);
     }
     $this->queues = $queueObjects;
     if (is_array($this->strategy)) {
         $this->strategy = \Yii::createObject($this->strategy);
     } else {
         if ($this->strategy instanceof Strategy) {
             throw new \yii\base\InvalidConfigException('The strategy field have to implement UrbanIndo\\Yii2\\Queue\\Strategies\\Strategy');
         }
     }
     $this->strategy->setQueue($this);
 }
Beispiel #3
0
 /**
  * @return void
  */
 public function init()
 {
     parent::init();
     $this->db = \yii\di\Instance::ensure($this->db, \yii\db\Connection::className());
 }
Beispiel #4
0
 /**
  * Initialize the queue component.
  * @return void
  */
 public function init()
 {
     parent::init();
     $this->_client = SqsClient::factory($this->config);
 }