*/ class Mage_Core_Model_Flag extends Mage_Core_Model_Abstract { /** * Flag code * * @var string */ protected $_flagCode = null; /** * Init resource model * Set flag_code if it is specified in arguments * */ protected function _construct() { if ($this->hasData('flag_code')) { $this->_flagCode = $this->getData('flag_code'); } $this->_init('core/flag'); } /** * Processing object before save data * * @return Mage_Core_Model_Flag */ protected function _beforeSave() { if (is_null($this->_flagCode)) { Mage::throwException(Mage::helper('core')->__('Please define flag code.')); } $this->setFlagCode($this->_flagCode); $this->setLastUpdate(date('Y-m-d H:i:s')); return parent::_beforeSave(); } /** * Retrieve flag data * * @return mixed */ public function getFlagData() { if ($this->hasFlagData()) { return unserialize($this->getData('flag_data')); } else { return null; } } /** * Set flag data * * @param mixed $value * @return Mage_Core_Model_Flag */ public function setFlagData($value) { return $this->setData('flag_data', serialize($value)); } /** * load self (load by flag code) * * @return Mage_Core_Model_Flag */ public function loadSelf() { if (is_null($this->_flagCode)) { Mage::throwException(Mage::helper('core')->__('Please define flag code.')); } return $this->load($this->_flagCode, 'flag_code'); } }