That makes perfect sense, but my main point is really about error handling when the user instantiates a modResource object and saves it.
Here's the resource/create processor code:
/* get the class_key to determine resourceClass ... */
$resourceClass = !empty($scriptProperties['class_key']) ?
$scriptProperties['class_key']
: 'modDocument';
Shouldn't the resource->save() code do the same thing?
If modResource is really meant to be an abstract class as far as the DB is concerned, should we ever allow users to save a modResource object with a class_key of 'modResource'?
[Update] Having looked at the code, I guess what I'm actually suggesting is this change to the save() method of modResource (unless there's some legitimate reason for creating a resource with a class_key of 'modResource' ):
public function save($cacheFlag= null) {
if ($this->isNew()) {
+++if ($this->get('class_key') == 'modResource') $this->set('class_key', 'modDocument');
if (!$this->get('createdon')) $this->set('createdon', time());
if (!$this->get('createdby') && $this->xpdo instanceof modX) $this->set('createdby', $this->xpdo->getLoginUserID());
}
[ed. note: BobRay last edited this post 14 years, 10 months ago.]