public function __construct($tokenRecord = null) { $this->record = new Placid_TokenRecord(); $this->model = new Placid_TokenModel(); $this->tokenRecord = $tokenRecord; if (is_null($this->tokenRecord)) { $this->tokenRecord = Placid_TokenRecord::model(); } }
/** * Save a token * * @param object Placid_TokenModel object * * @return bool true or false if token has been saved */ public function saveToken(Placid_TokenModel &$model) { if ($id = $model->getAttribute('id')) { $record = $this->record->findByPk($id); } else { $record = new Placid_TokenRecord(); } $attributes = $model->getAttributes(); // Fix this, only saves as unsafe value $record->setAttributes($attributes, false); if ($record->save()) { $model->setAttribute('id', $record->getAttribute('id')); return true; } else { $model->addErrors($record->getErrors()); return false; } }
/** * Delete access token from the database. * * @param int $id * @return int The number of rows affected */ public function deleteTokenById($id) { return Placid_TokenRecord::model()->deleteByPk($id); }