Hello again,

I'm in the process of migrating our datatypes from PHP4 to PHP5 and had a look 
on the code in eZP to register datatypes.

Currently you register the NAME of the datatype and eZP searches in a very 
time consuming way for the file, that contains the CLASS for the datatype. 
Because there is no possibilty[1] in PHP to get the name of a class in a file 
you included, you have to put a line like the following in the file 
containing the datatype-class:

eZDataType::register( EZ_DATATYPESTRING_BIRTHDAY, "ezbirthdaytype" );

That's not PHP5-ish since a file defining a class should not contain any 
global code.

A very simple workaround and upgrade path could be:

1. Add the AvailableDataTypeClasses setting to content.ini, which defines the 
CLASS of a datatype.

2. Write an ezpDataType[2] interface with the method 
    public static getIdentifier();
    to return the NAME of a datatype.

3. Adapt eZDataType accordingly, to support both datatype models. I will send 
you a patch, if you're interested.

4. Deprecate the old datatype.

Cheers,

Thomas Koch

[1] I know, that there's a way with diff'ing get_declared_classes, but that's 
not nice.
[2] Wouldn't it be a good idea, to name all new created classes ezpXYZ, to get 
a new namespace for new classes replacing legacy classes?
-- 
Thomas Koch, Software Developer
http://www.koch.ro
-- 
Sdk-public mailing list
[email protected]
http://lists.ez.no/mailman/listinfo/sdk-public

Reply via email to