fuel/parser — pull request #48 by bakert (2012-07-01 12:12:18+00:00)
Title: Add support for the plugins_dir setting in Smarty.

View_Smarty exposes a bunch of options but not plugins_dir. This is necessary to get custom plugins working with Smarty.

I'm currently running the egregious hack below in the after method of my BaseController. Save me from it? :)

// After View_Smarty in fuel is patched to allow setting of a
// plugins_dir in config we won't need to do it like this.
if (is_object($this->canvas)) {
$rc = new \ReflectionClass($this->canvas);
if ($rc->hasMethod('parser')) {
$parser = $this->canvas->parser();
} elseif ($rc->hasProperty('_view')) {
$parser = $this->canvas->_view->parser();
} else {
throw new YokoException("Unable to initialize Smarty i18n plugin.");
}
$smartyParam = 'plugins_dir';
$ourPluginsDir = APPPATH . '/smarty';
$pluginsDir = array_merge($parser->$smartyParam, [$ourPluginsDir]);
$parser->$smartyParam = $pluginsDir;
}