Example #1
0
 /**
  * Update exchanges for every bank with strategy
  * 
  * @param type $tries_count
  * @param type $seconds_to_sleep
  */
 public function actionAll($tries_count = 5, $seconds_to_sleep = 10)
 {
     $banks_to_grab = ExchangeRateGrabberInfo::find()->where(['not', ['bank_id' => null]])->orderBy('bank_id')->all();
     foreach ($banks_to_grab as $bank) {
         $this->actionBank($bank->name, $tries_count, $seconds_to_sleep);
     }
 }
 /**
  * Constructor is getting database grabber info from class name
  * 
  * @throws \Exception Throws \Exception if echange rate grabber info not found
  */
 public function __construct()
 {
     $classname = $this->getBankName();
     $info = ExchangeRateGrabberInfo::find()->where(['name' => $classname])->one();
     if (empty($info)) {
         throw new \UnexpectedValueException("broken class: metadata for {$classname} not found");
     }
     $this->info = $info;
 }
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getStrategy()
 {
     return $this->hasOne(ExchangeRateGrabberInfo::className(), ['id' => 'strategy_id']);
 }