4 * Smarty Method GetTags
6 * Smarty::getTags() method
9 * @subpackage PluginsInternal
12 class Smarty_Internal_Method_GetTags
15 * Valid for Smarty and template object
22 * Return array of tag/attributes of all tags used by an template
24 * @api Smarty::getTags()
25 * @link http://www.smarty.net/docs/en/api.get.tags.tpl
27 * @param \Smarty_Internal_TemplateBase|\Smarty_Internal_Template|\Smarty $obj
28 * @param null|string|Smarty_Internal_Template $template
30 * @return array of tag/attributes
31 * @throws \SmartyException
33 public function getTags(Smarty_Internal_TemplateBase $obj, $template = null)
35 /* @var Smarty $smarty */
36 $smarty = $obj->_getSmartyObj();
37 if ($obj->_isTplObj() && !isset($template)) {
39 } elseif (isset($template) && $template->_isTplObj()) {
40 $tpl = clone $template;
41 } elseif (isset($template) && is_string($template)) {
42 /* @var Smarty_Internal_Template $tpl */
43 $tpl = new $smarty->template_class($template, $smarty);
44 // checks if template exists
45 if (!$tpl->source->exists) {
46 throw new SmartyException("Unable to load template {$tpl->source->type} '{$tpl->source->name}'");
50 $tpl->smarty = clone $tpl->smarty;
51 $tpl->smarty->_cache[ 'get_used_tags' ] = true;
52 $tpl->_cache[ 'used_tags' ] = array();
53 $tpl->smarty->merge_compiled_includes = false;
54 $tpl->smarty->disableSecurity();
55 $tpl->caching = false;
57 $tpl->compiler->compileTemplate($tpl);
58 return $tpl->_cache[ 'used_tags' ];
60 throw new SmartyException("Missing template specification");