/** * Proxy method to add an extension to Smarty * * @param \Slim\Views\SmartyExtension $smartyExtension * @throws \SmartyException */ public function addExtension(SmartyExtension $smartyExtension) { $plugins = $smartyExtension->getPlugins(); foreach ($plugins as $name => $plugin) { $this->smarty->registerPlugin($plugin['type'], $name, $plugin['callback']); } }
public function registerExtension($file) { if (is_file($file) && $this->isPHPFile($file)) { $params = $this->getExtensionParams($file); if ($params) { require_once $file; if (function_exists($params['callback'])) { $this->smartyInstance->registerPlugin($params['type'], $params['name'], $params['callback']); } } } }
/** * Method to add the Slim plugins to Smarty * * @param RouterInterface $router * @param string|\Slim\Http\Uri $uri */ public function addSlimPlugins(RouterInterface $router, $uri) { $smartyPlugins = new SmartyPlugins($router, $uri); $this->smarty->registerPlugin('function', 'path_for', [$smartyPlugins, 'pathFor']); $this->smarty->registerPlugin('function', 'base_url', [$smartyPlugins, 'baseUrl']); }
/** * Proxy method to register a plugin to Smarty * * @param string $type plugin type * @param string $tag name of template tag * @param callback $callback PHP callback to register * @param boolean $cacheable if true (default) this function is cachable * @param array $cache_attr caching attributes if any * * @return self * * @throws SmartyException when the plugin tag is invalid */ public function registerPlugin($type, $tag, $callback, $cacheable = true, $cache_attr = null) { $this->smarty->registerPlugin($type, $tag, $callback, $cacheable, $cache_attr); }