coen-hyde/Shanty-Mongo — Issue #41: Issue setting AsReference object through property
Author: tholder
Created: 2011-10-08 21:42:22+00:00
State: open

Seems to be a bit of a bug/niggle when setting an object using a property setter. The works:

$data = array();
$data['appName'] = $this->_getParam('appName');
$data['urlKey'] = $this->_getParam('urlKey');
$data['owner'] = $this->company;
$data['createdBy'] = $this->user;

$app = new Model_Mongo_Application($data);
$app->save();

The following doesn't:

$app = new Model_Mongo_Application();
$app->appName = $this->_getParam('appName');
$app->urlKey = $this->_getParam('urlKey');
$app->owner = $this->company;
$app->createdBy = $this->user;
$app->save();

It produces:

Shanty_Mongo_Exception: Property 'owner' must not be null. in /Users/tholder/Sites/listenablefe/library/Shanty/Mongo/Document.php on line 805

Model is defined with requirements like:

protected static $_requirements = array(
'appName' => array('Required'),
'urlKey' => array('Required'),
'owner' => array('Document:Model_Mongo_Company', 'AsReference', 'Required'),
'createdBy' => array('Document:Model_Mongo_User', 'AsReference', 'Required')
);