3093 Posts in 875 Topics by 654 members
|
Page:
1
|
Go to End | |
| Author | Topic: | 945 Views |
-
Extending DataObject but still need to call static DataObject methods?

17 May 2011 at 3:12am
I'm trying to build my site around subclassing DataObject and using ModelAdmin for administrating in the CMS. I want to follow the practise of thick models and thin controllers, so essentially put all the data fetching in the models and then have thin controllers that just call model methods.
What I'm having trouble with is that when I extend DataModel like so: -
class Product extends DataModel {...}
I then still need to call DataModel::get(...) within in order to fetch data. What seems to be a normal OO approach would be to be able to make a call something like this: -
$this->get() or self::get()
In order to fetch all my products. It seems that I need to call DataModel::get('Product') even though I've subclassed DataModel. It may be that I've just missed something, but I can't grasp what the approach is supposed to be here. Subclassing DataModel and then still having to tell my data fetch calls which model to fetch from seems odd.
-
Re: Extending DataObject but still need to call static DataObject methods?

17 May 2011 at 8:22am
You can use $this->instance_get(), which accepts the same arguments as DataObject::get(), just not the class name.
-
Re: Extending DataObject but still need to call static DataObject methods?

17 May 2011 at 9:13pm
Great, thanks a lot!
| 945 Views | ||
|
Page:
1
|
Go to Top |

