fuel / parser

Fuel PHP Framework - v1.x template parser package adapters
http://fuelphp.com
64 stars 45 forks source link

Add support for the plugins_dir setting in Smarty. #48

Closed bakert closed 12 years ago

bakert commented 12 years ago

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;
    }