I have two models similar to the following:
class Job extends CActiveRecord
{
public $languages;
public $workAreas;
public $professions;
public $qualifications;
public function afterSave()
{
if ($this->scenario == 'saveItems') $this->saveItems();
}
public function saveItems()
{
//code to process and save the above properties
}
}
class User extends CActiveRecord
{
public $languages;
public $workAreas;
public $professions;
public $qualifications;
public function afterSave()
{
if ($this->scenario == 'saveItems') $this->saveItems();
}
public function saveItems()
{
//code to process and save the above properties
}
}
None of the properties are database fields, they are all processed into something else in the saveItems() field. I update the properties via a form, so they are all designated as ‘safe’ in the rules array
This violates DRY (Don’t Repeat Yourself), so I’d like to move this functionality into a behavior. What’s the best way for me to move the public properties into the behaviour?. I’ve thought of using getLanguages(), setLanguages() etc, but that seems a long way round, given than I have about 20 properties in total.