Forums / Developer / Extending built-in datatypes
Piotrek Karaś
Thursday 10 January 2008 11:59:24 pm
Hello,
Is extending built-in datatypes when creating a custom datatype a good idea? Example:
class MyCustomURLType extends eZURLType {...}
I've used it before, but recently came across a problem - the extended datatype was not found. What could be the key to this? Is that because the extended class was not called earlier in the code? Any way of securing that?
BTW. Mostly interested in eZ4...
Thanks,Piotrek
-- Company: mediaSELF Sp. z o.o., http://www.mediaself.pl eZ references: http://ez.no/partners/worldwide_partners/mediaself eZ certified developer: http://ez.no/certification/verify/272585 eZ blog: http://ez.ryba.eu
André R.
Friday 11 January 2008 12:58:10 am
> Is extending built-in datatypes when creating a custom datatype a good idea? Example:Depends one the probability of big changes in the datatype in the future.
> I've used it before, but recently came across a problem - the extended datatype was not found. 1. make sure the class is in the autoload array "autoload/*"2. if not, simply include it like you did in ezp3.x
eZ Online Editor 5: http://projects.ez.no/ezoe || eZJSCore (Ajax): http://projects.ez.no/ezjscore || eZ Publish EE http://ez.no/eZPublish/eZ-Publish-Enterprise-Subscription @: http://twitter.com/andrerom
Friday 11 January 2008 1:58:36 am
> Depends one the probability of big changes in the datatype in the future.
Yes. I'm thinking of extending instead of creating from scratch when I only need to slightly adjust the built in functionality, for example to provide additional validation rules. URL is a good example, because it is quite a complex datatype with core functionality that I want to still rely on, I just need little extra protection. I expect this way to be much easier to maintain when changes are introduced to datatypes in future versions. Do you think I miss something?
Thanks for the help,Piotrek