Admin_ElementController::findUsagesAction PHP Method

findUsagesAction() public method

public findUsagesAction ( )
    public function findUsagesAction()
    {
        if ($this->getParam("id")) {
            $element = Element\Service::getElementById($this->getParam("type"), $this->getParam("id"));
        } elseif ($this->getParam("path")) {
            $element = Element\Service::getElementByPath($this->getParam("type"), $this->getParam("path"));
        }
        $results = [];
        $success = false;
        if ($element) {
            $elements = $element->getDependencies()->getRequiredBy();
            foreach ($elements as $el) {
                $item = Element\Service::getElementById($el["type"], $el["id"]);
                if ($item instanceof Element\ElementInterface) {
                    $el["path"] = $item->getRealFullPath();
                    $results[] = $el;
                }
            }
            $success = true;
        }
        $this->_helper->json(["data" => $results, "success" => $success]);
    }