public function insert() { parent::insert(); if (empty($this->log)) { if (!$this->log_id->getValue()) { throw new \NotFoundException('Log record not set. Record can`t be added '); } $this->log = new Log(); $this->log->get($this->log_id->getValue()); } if ($this->log->critical->getValue()) { $this->sendEmailNotification(); } }
/** * @param $id * * @return Log */ public static function getById($id) { $result = new Log(); $found = $result->get($id); if (empty($found)) { throw new \NotFoundException('Log record not found'); } return $result; }
public function testSetupLogging() { $api = new EditLog(array('name' => 'Log1', 'enable_logging' => 0)); $api->exec(); $log = new Log(); $log->get(1); $this->assertEquals(0, $log->enable_logging->getValue()); $api = new EditLog(array('name' => 'Log1', 'enable_logging' => 1)); $api->exec(); // $log = new Log(); $log->get(1); $this->assertEquals(1, $log->enable_logging->getValue()); }