public function init() { // add all task defined as Task::execute to the conditions $modelTaskDefined = new TaskDefined(); $tasksdefined = $modelTaskDefined->getTaskDefinedAll(); foreach ($tasksdefined as $taskdefined) { $this->conditions[sprintf('{"class":"Task","function":"execute","parameter":["%d","%d","%d"]}', $taskdefined['from_device_id'], $taskdefined['to_device_id'], $taskdefined['action_id'])] = sprintf('(%d) %s', $taskdefined['id'], $taskdefined['name']); } // translate all conditions foreach ($this->conditions as $json => $condition) { $this->conditions[$json] = Yii::t('app', $condition); } // add date, condition or task before value condition foreach ($this->conditions as $json => $condition) { $array = json_decode($json, true); switch ($array['class']) { case 'php': switch ($array['function']) { case 'date': $this->conditions[$json] = sprintf('date(\'%s\'), %s', $array['parameter'], $condition); break; } break; default: $this->conditions[$json] = sprintf('%s, %s', $array['class'], $condition); } } // translate all equations foreach ($this->equations as $key => $equation) { $this->equations[$key] = Yii::t('app', $equation); } // key before value equations foreach ($this->equations as $key => $equation) { $this->equations[$key] = $key . ', ' . $equation; } // create weights from 0 to 10 for ($weight = 0; $weight <= 10; $weight++) { $this->weights[$weight] = $weight; } parent::init(); }