/** * @param null $id * @throws \Exception */ public function getById($id = null) { if (!$id) { $id = $this->model->getId(); } $classRaw = $this->db->fetchRow("SELECT * FROM classes WHERE id = ?", $id); if ($classRaw["id"]) { $this->assignVariablesToModel($classRaw); $this->model->setPropertyVisibility(Serialize::unserialize($classRaw["propertyVisibility"])); $this->model->setLayoutDefinitions($this->getLayoutData()); } else { throw new \Exception("Class with ID " . $id . " doesn't exist"); } }