/**
  * @inheritdoc
  */
 public function beforeActionRun()
 {
     parent::beforeActionRun();
     if (false === class_exists($this->className)) {
         throw new InvalidParamException(Yii::t('dotplant.currencies', 'Class "{className}" not found!', ['className' => $this->className]));
     }
     if (false === file_exists(Yii::getAlias($this->storage))) {
         throw new InvalidParamException(Yii::t('dotplant.currencies', '"{storage}" is not valid "{itemName}" storage file!', ['storage' => $this->storage, 'itemName' => $this->itemName]));
     }
     $itemName = Yii::$app->request->get('id', '');
     $this->returnUrl = Yii::$app->request->get('returnUrl', '');
     $class = $this->className;
     if (true === empty($itemName)) {
         $this->model = new $class(['scenario' => $class::SCENARIO_NEW]);
         $this->model->setDefaults();
     } else {
         $this->model = $class::getByName($itemName);
     }
     if (null === $this->model) {
         throw new NotFoundHttpException(mb_convert_case($this->itemName, MB_CASE_TITLE, "UTF-8") . Yii::t('dotplant.currencies', ' {name} not found!', ['name' => $itemName]));
     }
 }
 public function testUpdateStorage()
 {
     $a = ['name' => 'Newerlands peso', 'iso_code' => 'NPS', 'is_main' => 1, 'format_string' => '# pps.', 'intl_formatting' => 0];
     $c = new Currency();
     $c->setDefaults();
     $c->setAttributes($a);
     FunctionalHelper::flushStorage($c->getStorage());
     CurrencyStorageHelper::updateStorage($c);
     $this->assertFileExists($c->getStorage());
     $curr = [];
     if (true === file_exists($c->getStorage())) {
         $curr = (include $c->getStorage());
     }
     $this->assertNotEmpty($curr);
     $this->assertCount(1, $curr);
     $this->assertArrayHasKey($a['name'], $curr);
     FunctionalHelper::flushStorage($c->getStorage());
 }