public function getDocTypesAction() { $list = new Document\DocType\Listing(); if ($this->getParam("type")) { $type = $this->getParam("type"); if (Document\Service::isValidType($type)) { $list->setFilter(function ($row) use($type) { if ($row["type"] == $type) { return true; } return false; }); } } $list->load(); $docTypes = array(); foreach ($list->getDocTypes() as $type) { $docTypes[] = $type; } $this->_helper->json(array("docTypes" => $docTypes)); }
public function getDocTypesAction() { $list = new Document\DocType\Listing(); if ($this->getParam("type")) { $type = $this->getParam("type"); if (Document\Service::isValidType($type)) { $list->setCondition("type = ?", $type); } } $list->setOrderKey(array("priority", "name")); $list->setOrder(array("desc", "ASC")); $list->load(); $docTypes = array(); foreach ($list->getDocTypes() as $type) { $docTypes[] = $type; } $this->_helper->json(array("docTypes" => $docTypes)); }
/** * @param $name * @return DocType */ private static function getDocumentTypeByName($name) { $doctypeListing = new DocTypeListing(); $doctypes = $doctypeListing->getDocTypes(); /** @var DocType $docType */ foreach ($doctypes as $docType) { if ($docType->getName() == $name) { return $docType; } } $docType = new DocType(); $docType->name = $name; return $docType; }