Arbit - project tracking

Dwoo

#73: Compilable function plugin as class dont get recognized as compilable

Issue revisions

  • new by JoeScylla at 2010-J-23 12:40
  • closed by Jordi Boggiano at 2010-J-15 0:06
Type bug bug
State closed closed
Priority low low
Resolution fixed fixed
Assigned to Nobody
Scheduled for 1.2.0
Affected versions 1.1.1
Affected components Core
Last change Thursday 15 July 2010 00:06:55 UTC by Jordi Boggiano
Short description
-----------------
Compilable function plugin as class dont get recognized as compilable

Environment
-----------
Apache/2, PHP 5.2.x

Steps to reproduce
------------------

PHP-Code:

class RendererPluginBreak extends Dwoo_Plugin implements Dwoo_ICompilable
	{
	 public static function compile(Dwoo_Compiler $compiler)
		{
		return Dwoo_Compiler::PHP_OPEN .  " break; " . Dwoo_Compiler::PHP_CLOSE;
		}
	}
$dwoo = new Dwoo();
$dwoo->addPlugin("Break", "RendererPluginBreak", true);

Template-Code:

{foreach $someIterator item}
	{$item}
	{Break}
{/foreach}

Expected behavior
-----------------
The string "<?php break; ?>" getting written into the compiled template file.

Actual behavior
---------------
ReflectionException Exception is thrown with the message:

"Method RendererPluginBreak::process() does not exist
triggered in file /lucid/libaries/dwoo/Dwoo/Compiler.php at line 3050."
  • Jordi Boggiano at Wednesday 23 June 2010 12:46:20 UTC

    I'll try to check that somewhen but meanwhile I'd advise you to just do it with a normal function plugin, no need to overblow it with a class. I think this should do the trick:

    function Dwoo_Plugin_break_compile(Dwoo_Compiler $compiler) {

    return '""; break;';

    }

  • Jordi Boggiano at Wednesday 23 June 2010 12:48:15 UTC

    Goddamn RST markup, I hope this will be more readable:

    function Dwoo_Plugin_break_compile(Dwoo_Compiler $compiler) {
        return '""; break;';
    }
    
    
  • JoeScylla at Wednesday 23 June 2010 12:54:02 UTC

    Thanks for the freaking fast answer ;). I already created a compiler function as you suggested. The only reason i used a class for that mini-task is because of the PHP autoloading.

  • Jordi Boggiano at Thursday 15 July 2010 00:06:55 UTC

    Fixed and pushed to git master, it'll be available in svn trunk shortly. There is still one small issue in the fact that you can't use the "Dwoo_Compiler $compiler" argument because it's not passed to custom plugins. I sort of could fix that but it's too complex to do it now.. Besides that issue is long known and has an issue already as http://bugs.dwoo.org/dwoo/bugs/issue/10