Skip to content

Commit

Permalink
changed Interpolator to substitute $params[name]
Browse files Browse the repository at this point in the history
  • Loading branch information
hiqsol committed Apr 18, 2017
1 parent 9f7ab14 commit 83baf53
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions src/components/Interpolator.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,22 +14,20 @@ public function interpolate(&$data)
$this->interpolate($item);
}
} elseif (is_string($data)) {
$data = preg_replace_callback('/\{{ (.*?) }}/', function ($matches) {
return $this->get($matches[1]);
$data = preg_replace_callback('/\\$(\\w+)\\[\'(.+?)\'\\]/', function ($matches) {
return $this->get($matches[1], $matches[2]);
}, $data);
}
}

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

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

Expand Down

0 comments on commit 83baf53

Please sign in to comment.