Webiny\Component\TemplateEngine\Bridge\Smarty\Smarty::registerPlugin PHP 메소드

registerPlugin() 공개 메소드

Register a plugin for the template engine.
public registerPlugin ( Plugin $plugin ) : void
$plugin Webiny\Component\TemplateEngine\Plugin
리턴 void
    public function registerPlugin(Plugin $plugin)
    {
        try {
            $this->smarty->registerPlugin($plugin->getType(), $plugin->getName(), $plugin->getCallbackFunction(), $plugin->getAttribute('Cachable', true), $plugin->getAttribute('CacheAttr', null));
        } catch (\SmartyException $e) {
            throw new SmartyException($e);
        }
    }

Usage Example

예제 #1
0
 /**
  * @dataProvider dataProvider
  */
 public function testRegisterPlugin(Smarty $smarty)
 {
     $plugin = new PluginMock();
     $smarty->registerPlugin($plugin);
     $smarty->assign('name', 'world');
     $result = $smarty->fetch('TestPlugin.tpl');
     $this->assertSame('Hello WORLD', $result);
 }