noiselabs / SmartyBundle

Smarty3 template engine bundle for Symfony
http://smartybundle.readthedocs.io/
GNU Lesser General Public License v3.0
51 stars 36 forks source link

Invalid format for plugins_dir #40

Closed keltanas closed 10 years ago

keltanas commented 10 years ago

If I need to install a plugin directory, then Smarty ceases to see the default directory. This is because the function setPluginsDir, through which there is a pass option plugins_dir

class Smarty extends Smarty_Internal_TemplateBase

    public function setPluginsDir($plugins_dir)
    {
        $this->plugins_dir = array();
        foreach ((array) $plugins_dir as $k => $v) {
            $this->plugins_dir[$k] = rtrim($v, '/\\') . DS;
        }

        return $this;
    }

erases the specified directory and sets new.

I think it would be good to give the ability to set an array plugins_dir

->arrayNode('plugins_dir')
    ->prototype('scalar')->end()
->end()
smarty:
    options:
        plugins_dir:
            - %kernel.root_dir%/../vendor/smarty/smarty/distribution/libs/plugins
            - %kernel.root_dir%/Resources/plugins
vitorbrandao commented 10 years ago

Hello @keltanas, thanks for reporting this issue. I'll look into it.

keltanas commented 10 years ago

As a solution for the current version, decided to use a pass

class SmartyCompilerPass implements CompilerPassInterface
{
    public function process(ContainerBuilder $container)
    {
        if ($container->has('templating.engine.smarty')) {
            $smartyDefinition = $container->getDefinition('templating.engine.smarty');
            $smartyDefinition
                ->addMethodCall('addPluginsDir', array(
                    '%kernel.root_dir%/../vendor/smarty/smarty/distribution/libs/plugins'
                ))
                ->addMethodCall('addPluginsDir', array(
                    '%kernel.root_dir%/Resources/plugins'
                ))
            ;
        }
    }
}
vitorbrandao commented 10 years ago

@keltanas sorry for the delay. The bugfix is now available in master, check if it works for you without the custom compiler pass.

keltanas commented 10 years ago

@noisebleed ok, thank you