joelwan / php-object-generator

ORM class generator for PHP
http://www.phpobjectgenerator.com
29 stars 30 forks source link

plugin instantiation at pog_base #6

Closed Loksly closed 10 years ago

Loksly commented 12 years ago

Hi Joel,

I'm going to develop a "GetBy" plugin so you can use code like these:

$o = new object();
$objects = $o->GetByDate($value);

which should equivalent to

$o->GetList(array(array('Date','=',$value));

I'm still wondering if I should use just a plugin with name "GetBy" or rewrite the __call method at the classes where I want the functionality to work.

Well, the fact is that looking at the pog_base code I've seen that the plugin instantiation is done this way:

        eval('$plugin = new $method($this,$argv);');

and I was wondering why not to use:

        $plugin = new $method($this,$argv);

I've changed the code in my projects and it seems to be working using the second line. I don't know if there is any reason for using eval, is there any?

Have a nice day!

joelwan commented 12 years ago

cool. I think a plugin is good, rewriting the call method will go against what POG was originally designed for, and make it closer to what Cake or Rails do.

Are you thinking that your GetByPlugin could also do things like

GetByAttribute1And|OrAttribute2...AttributeN(val1, val2, ... valN)

If so, that would which would make it just as flexible as GetList but make it more verbose. That would be a pretty awesome plugin I think!

As for the eval, I'm not too sure right now why it was done this way. I'll have to look into it