/** * Fires an event * * @return boolean Returns true if a new record has been added */ public function fire() { $this->timelineEvent->uuid = $this->timelineEvent->type('uuid')->toPhp(substr(hash('sha1', $this->messageToHash, true), 0, 16)); if (!$this->timelineEvent->findPk($this->timelineEvent->uuid)) { $this->timelineEvent->description = $this->message; $this->timelineEvent->save(); //Creates timeline event records for events which affect cost centers foreach (array_filter($this->ccs, [$this, 'callbackFilter']) as $ccId) { $entity = new TimelineEventCostCentreEntity($this->timelineEvent->uuid, $ccId); $entity->save(); } //Creates timeline event records for events which affect projects foreach (array_filter($this->projects, [$this, 'callbackFilter']) as $projectId) { $entity = new TimelineEventProjectEntity($this->timelineEvent->uuid, $projectId); $entity->save(); } return true; } return false; }
protected function run1($stage) { $this->db->Execute(' ALTER TABLE `timeline_events` ADD `account_id` int(11) NULL AFTER `user_id`, ADD `env_id` int(11) NULL AFTER `account_id`, ADD INDEX `idx_account_id` (`account_id` ASC), ADD INDEX `idx_env_id` (`env_id` ASC) '); $res = $this->db->Execute('SELECT * FROM timeline_events'); while ($item = $res->FetchRow()) { $event = new TimelineEventEntity(); $event->load($item); try { $event->accountId = \Scalr_Account_User::init()->loadById($event->userId)->getAccountId(); } catch (Exception $e) { continue; } $event->save(); } }