Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

General Questions

General questions about getting started with SilverStripe that don't fit in any of the categories above.

Moderators: martimiz, Sean, biapar, Willr, Ingo, swaiba, simon_w

Iterating through classes with an extension


3 Posts   270 Views


28 February 2013 at 5:24am Community Member, 6 Posts

How can I get a list of all classes extended by a DataExtension?



28 February 2013 at 8:54pm Forum Moderator, 5511 Posts

Going that way might be tricky Object::has_extension($class, $extension) would be one piece of API that would help, though you would need to get a list of classes though. ClassInfo::subclassesFor('DataObject') will give you an array of dataobject classes so you could use both

foreach(ClassInfo::subclassesFor('DataObject') as $className) {
if(Object::has_extension($className, 'YourExtension')) {
// class has extension


28 February 2013 at 11:23pm Community Member, 6 Posts

I solved with:

foreach(ClassInfo::subclassesFor('DataObject') as $class ) {
if (singleton($class)->hasExtension("ZkTwitterExtension")) {

Do you think your version is more performat, or they're the same?