extension for yii1
This extension help to save model state before updating and check which attribute has been changed., (*1)
For example, you want to check if user name changed or not and after update some cache and etc., (*2)
public function beforeSave() { if($this->itChanged('username')) echo 'changed'; else echo 'not changed'; }
You also can see how it changed. Use method $this->getModelState() This method return associative array: [ %attribute_name% => %attribute_value%, ... ], (*3)
I recommended use trait. (only for PHP >= 5.4.0) For example:, (*4)
class User extends CActiveRecord { use ItChangedExtension\ItChangedTrait; }
Simple, after use your class extending functional from trait., (*5)
But extension support old way to use throw extend. If you have model which extend CActiveRecord, you just change extend to ItChangedActiveRecord class Same with CForm and CModel, (*6)
For import files if you not use composer, just add include_once in your index.php before yii set up., (*7)
{ "require": { "one-art/itchanged": "*" } }