Re: Re: Structures_DataGrid_Renderer - doesnt' allow custom renderers outside of PEAR directory tree
| From: | Olivier Guilyardi | Date: | Sun, 30 Jan 2005 01:46:19 +0000 |
| Subject: | Re: Re: Structures_DataGrid_Renderer - doesnt' allow custom renderers outside of PEAR directory tree | ||
| References: | 1 2 3 4 5 | Groups: | php.pear.general |
| Request: | Send a blank email to pear-general+get-17274@lists.php.net to get a copy of this message | ||
Justin Patrin wrote:
On Fri, 28 Jan 2005 13:39:58 -0500, Andrew Nagy <asnagy@webitecture.org> wrote:On a Debian installation, PEAR files go into /usr/share/php, which is certainly not a place where to put your own application-specific stuff.Additionally, to the OP, it's prefectly reasonable to put your own file in the PEAR directories. I've been doing this with DB drivers and HTML_QuickForm elements for a while.
I agree, but then I thought about those who are using a hosting company who has the pear libraries available, but would obviosuly not have access to the pear directory.
True, which is why a class_exists call before the include makes sense. This also stops you from possibly calling include on an already included file...which is what the _once is for, but... And there is also the option of using a local directory structure set the same way and changing your include path.IMHO, it would be better to add something like attachRenderer(), which would take an already instantiated renderer as argument, not a class name. Example : class CustomRenderer { // rendering routines } $renderer = new CustomRenderer(); $renderer->setTableColor('pink'); $datagrid->attachRenderer($renderer); This way you'd be free to write your own renderer and to set it up before attaching it, according to some contextual parameters, as the setTableColor() method somehow illustrates. By the way, this is coherent with the bindDataSource() method, which takes an already instantiated datasource as argument, wether it is a built-in or a home-made driver. -- og