Skip to content

Commit

Permalink
added interpolation of data from config
Browse files Browse the repository at this point in the history
  • Loading branch information
hiqsol committed Apr 17, 2017
1 parent 8a5a611 commit 9f7ab14
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/components/Interpolator.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace hidev\components;

use Yii;
use yii\helpers\ArrayHelper;

class Interpolator
{
Expand All @@ -25,8 +26,17 @@ public function get($name)

if ($scope === 'params') {
return Yii::$app->params[$subname];
} elseif ($scope === 'config') {
return $this->getConfig($subname);
} else {
return null;
return $this->getConfig($name);
}
}

public function getConfig($name)
{
list($goal, $subname) = explode('.', $name, 2);

return ArrayHelper::getValue(Yii::$app->get('config')->getGoal($goal), $subname);
}
}

0 comments on commit 9f7ab14

Please sign in to comment.