context = DatabaseConnection::i()->getContext(); $this->templates = $this->context->table("support_templates"); } private function toTemplate(?ActiveRow $ar): ?SupportTemplate { return is_null($ar) ? NULL : new SupportTemplate($ar); } function get(int $id): ?SupportTemplate { return $this->toTemplate($this->templates->get($id)); } function getListByDirId(int $dir_id): \Traversable { foreach ($this->templates->where(["dir" => $dir_id, "deleted" => 0]) as $template) yield new SupportTemplate($template); } }