/**
* Returns the element data denoted by the given type and ID or path.
*/
public function getSubtypeAction()
{
$idOrPath = trim($this->getParam("id"));
$type = $this->getParam("type");
if (is_numeric($idOrPath)) {
$el = Element\Service::getElementById($type, (int) $idOrPath);
} else {
if ($type == "document") {
$el = Document\Service::getByUrl($idOrPath);
} else {
$el = Element\Service::getElementByPath($type, $idOrPath);
}
}
if ($el) {
if ($el instanceof Asset || $el instanceof Document) {
$subtype = $el->getType();
} elseif ($el instanceof Object\Concrete) {
$subtype = $el->getClassName();
} elseif ($el instanceof Object\Folder) {
$subtype = "folder";
}
$this->_helper->json(["subtype" => $subtype, "id" => $el->getId(), "type" => $type, "success" => true]);
} else {
$this->_helper->json(["success" => false]);
}
}