Extend default handler

This commit is contained in:
uwetews
2016-07-12 23:37:51 +02:00
parent bfca72e71b
commit e494f65a77
2 changed files with 17 additions and 1 deletions

View File

@@ -56,6 +56,10 @@ class DefaultPluginHandlerTest extends PHPUnit_Smarty
{ {
$this->assertEquals("echo 'scriptcompilerfunction '.'foo bar';", $this->smarty->fetch('test_default_compiler_function_script.tpl')); $this->assertEquals("echo 'scriptcompilerfunction '.'foo bar';", $this->smarty->fetch('test_default_compiler_function_script.tpl'));
} }
public function testDefaultCompilerObject()
{
$this->assertEquals('Public World', $this->smarty->fetch('test_default_compiler_object.tpl'));
}
public function testDefaultBlockScript() public function testDefaultBlockScript()
{ {
@@ -117,7 +121,9 @@ function my_plugin_handler($tag, $type, $template, &$callback, &$script, &$cacha
case 'scriptcompilerfunction': case 'scriptcompilerfunction':
$script = './scripts/script_compiler_function_tag.php'; $script = './scripts/script_compiler_function_tag.php';
$callback = 'default_script_compiler_function_tag'; $callback = 'default_script_compiler_function_tag';
return true;
case 'compilerobject':
$callback = array(new CompilerDefaultPluginClass, 'compile');
return true; return true;
default: default:
return false; return false;
@@ -165,3 +171,12 @@ function default_local_modifier($input)
{ {
return 'localmodifier ' . $input; return 'localmodifier ' . $input;
} }
class CompilerDefaultPluginClass
{
static function statCompile ($params, $compiler) {
return '<?php echo \'Static World\';?>';
}
public function compile ($params, $compiler) {
return '<?php echo \'Public World\';?>';
}
}

View File

@@ -0,0 +1 @@
{compilerobject value='foo bar'}