Pimcore\Config::getRuntimeElementTreeConfig PHP Method

getRuntimeElementTreeConfig() protected static method

Returns the element tree config for the given config name
protected static getRuntimeElementTreeConfig ( $name ) : array
$name
return array
    protected static function getRuntimeElementTreeConfig($name)
    {
        $masterConfig = self::getPerspectivesConfig()->toArray();
        $config = $masterConfig[$name];
        if (!$config) {
            $config = [];
        }
        $tmpResult = $config["elementTree"];
        if (is_null($tmpResult)) {
            $tmpResult = [];
        }
        $result = [];
        $cfConfigMapping = [];
        $cvConfigs = Tool::getCustomViewConfig();
        if ($cvConfigs) {
            foreach ($cvConfigs as $node) {
                $tmpData = $node;
                if (!isset($tmpData["id"])) {
                    Logger::error("custom view ID is missing " . var_export($tmpData, true));
                    continue;
                }
                if ($tmpData["hidden"]) {
                    continue;
                }
                // backwards compatibility
                $treeType = $tmpData["treetype"] ? $tmpData["treetype"] : "object";
                $rootNode = Model\Element\Service::getElementByPath($treeType, $tmpData["rootfolder"]);
                if ($rootNode) {
                    $tmpData["type"] = "customview";
                    $tmpData["rootId"] = $rootNode->getId();
                    $tmpData["allowedClasses"] = $tmpData["classes"] ? explode(",", $tmpData["classes"]) : null;
                    $tmpData["showroot"] = (bool) $tmpData["showroot"];
                    $customViewId = $tmpData["id"];
                    $cfConfigMapping[$customViewId] = $tmpData;
                }
            }
        }
        foreach ($tmpResult as $resultItem) {
            if ($resultItem["hidden"]) {
                continue;
            }
            if ($resultItem["type"] == "customview") {
                $customViewId = $resultItem["id"];
                if (!$customViewId) {
                    Logger::error("custom view id missing " . var_export($resultItem, true));
                    continue;
                }
                $customViewCfg = $cfConfigMapping[$customViewId];
                if (!$customViewId) {
                    Logger::error("no custom view config for id  " . $customViewId);
                    continue;
                }
                foreach ($resultItem as $specificConfigKey => $specificConfigValue) {
                    $customViewCfg[$specificConfigKey] = $specificConfigValue;
                }
                $result[] = $customViewCfg;
            } else {
                $result[] = $resultItem;
            }
        }
        usort($result, function ($treeA, $treeB) {
            $a = $treeA["sort"] ? $treeA["sort"] : 0;
            $b = $treeB["sort"] ? $treeB["sort"] : 0;
            if ($a > $b) {
                return 1;
            } elseif ($a < $b) {
                return -1;
            } else {
                return 0;
            }
        });
        return $result;
    }