/** * This method prevents setting some * values directly * * (non-PHPdoc) * * @see ArrayObject::offsetSet() * * @param mixed $index * @param mixed $newval * * @throws DevException */ public function offsetSet($index, $newval) { switch ($index) { case 'accepted': throw new DevException('value of accepted cannot be set directly. Use setAccepted() or unsetAccepted() methods'); break; case 'i_comments': throw new DevException('value of i_comments cannot be set directly. Use increaseCommentsCount() method'); break; case 'comments': case 'a_comments': throw new DevException('value of a_comments cannot be set directly. Must use setComments() method for that'); break; case 'i_down': case 'i_up': case 'i_votes': throw new DevException('value of ' . $index . ' keys cannot be set directly. Use addDownVote or addUpVote to add votes'); break; case 'a_deleted': case 'i_del_ts': throw new DevException('value of ' . $index . ' cannot be set directly. Must use setDeleted() method for that'); break; case 'a_edited': throw new DevException('value of a_edited cannot be set directly. Must use setEdited() method for that'); break; default: parent::offsetSet($index, $newval); } }
/** * Some keys should not be set directly * but instead use proper setter methods * * @todo must go over all classes and see * which classes set values directly using * ->offsetSet or as assignment * and add some of the more important * keys here. For example: language, locale, * ,username(maybe), pwd(maybe), email, * timezone should go through validation * * (non-PHPdoc) * @see ArrayObject::offsetSet() * * @param mixed $index * @param mixed $newval * * @throws DevException */ public function offsetSet($index, $newval) { switch ($index) { case Schema::ROLE: throw new DevException('User Role cannot be set directly, must be set using setRoleId() method'); //$this->setRoleId($newval); break; case Schema::REPUTATION: throw new DevException('value of i_rep cannot be set directly. Use setReputation() method'); break; case Schema::TIMEZONE: case 'timezone': //$this->setTimezone($newval); throw new DevException('Value of timezone should be set using setTimezone() method'); break; default: parent::offsetSet($index, $newval); } }
/** * This method prevents setting some * values directly * * (non-PHPdoc) * @see ArrayObject::offsetSet() */ public function offsetSet($index, $newval) { switch ($index) { case 'i_comments': throw new DevException('value of i_comments cannot be set directly. Use increaseCommentsCount() method'); break; case 'i_down': case 'i_up': case 'i_votes': throw new DevException('value of ' . $index . ' keys cannot be set directly. Use addDownVote or addUpVote to add votes'); break; case 'a_deleted': case 'i_del_ts': throw new DevException('value of ' . $index . ' cannot be set directly. Must use setDeleted() method for that'); break; case 'i_ans': throw new DevException('value of i_ans cannot be set directly. Use updateAnswerCount() method'); break; case 'i_views': throw new DevException('value of i_ans cannot be set directly. Use increaseViews() method'); break; case 'a_edited': throw new DevException('value of a_edited cannot be set directly. Must use setEdited() method for that'); break; case 'a_closed': throw new DevException('value of a_closed cannot be set directly. Must use setClosed() method for that'); break; case 'comments': case 'a_comments': throw new DevException('value of a_comments cannot be set directly. Must use setComments() method for that'); break; /*case 'a_latest': throw new DevException('value of a_latest cannot be set directly. Must use setLatestAnswer() method for that'); break;*/ /*case 'a_latest': throw new DevException('value of a_latest cannot be set directly. Must use setLatestAnswer() method for that'); break;*/ case 'i_sel_uid': case 'i_sel_ans': throw new DevException('value of ' . $index . ' cannot be set directly. Must use setBestAnswer() method for that'); break; default: parent::offsetSet($index, $newval); } }
/** * Some keys should not be set directly * but instead use proper setter methods * * @todo must go over all classes and see * which classes set values directly using * ->offsetSet or as assignment * and add some of the more important * keys here. For example: language, locale, * ,username(maybe), pwd(maybe), email, * timezone should go through validation * * (non-PHPdoc) * @see ArrayObject::offsetSet() */ public function offsetSet($index, $newval) { switch ($index) { case 'role': throw new DevException('User Role cannot be set directly, must be set using setRoleId() method'); //$this->setRoleId($newval); break; case 'i_pp': throw new DevException('value of i_pp cannot be set directly. Use setProfitPoint() method'); break; case 'tz': case 'timezone': //$this->setTimezone($newval); throw new DevException('Value of timezone should be set using setTimezone() method'); break; default: parent::offsetSet($index, $newval); } }