/** * Set up the foreign key of the parent before storing. * * @throws Opus_Model_Exception Thrown if trying to store without parent. * @return mixed $id Primary key of the models primary table row. */ public function store() { if (null === $this->_parentId) { throw new Opus_Model_Exception('Dependent Model ' . get_class($this) . ' without parent cannot be persisted.'); } if (null === $this->_parentColumn) { throw new Opus_Model_Exception('Dependent Model ' . get_class($this) . ' needs to know name of the parent-id column.'); } $this->_primaryTableRow->{$this->_parentColumn} = $this->_parentId; return parent::store(); }
/** * Stores the accounts credentials. Throws exception if something failes * during the store operation. * * @throws Opus_Security_Exception If storing failes. * @return void */ public function store() { // Check for a proper credentials if ($this->isValid() === false) { throw new Opus_Security_Exception('Credentials are invalid.'); } // Check if there is a account with the same // loginname before creating a new record. if (is_null($this->getId()) === true) { $row = Opus_Account::fetchAccountRowByLogin($this->getLogin()); if (is_null($row) === false) { throw new Opus_Security_Exception('Account with login name ' . $this->getLogin() . ' already exists.'); } } // Now really store. try { return parent::store(); } catch (Exception $ex) { $logger = Zend_Registry::get('Zend_Log'); if (null !== $logger) { $message = "Unknown exception while storing account: "; $message .= $ex->getMessage(); $logger->err(__METHOD__ . ': ' . $message); } $message = "Caught exception. Please consult the server logfile."; throw new Opus_Security_Exception($message); } }