getByKeyLocalized() публичный статический Метод

public static getByKeyLocalized ( $id, boolean $create = false, boolean $returnIdIfEmpty = false, null $language = null ) : string
$id
$create boolean
$returnIdIfEmpty boolean
$language null
Результат string
Пример #1
0
 private function translateLabel($key)
 {
     try {
         return \Pimcore\Model\Translation\Admin::getByKeyLocalized($key, false, true);
     } catch (\Exception $e) {
         return $key;
     }
 }
Пример #2
0
 public function getTreeAction()
 {
     $defaultIcon = "/pimcore/static6/img/flat-color-icons/timeline.svg";
     if (!\Pimcore\Tool\Admin::isExtJS6()) {
         $defaultIcon = '/pimcore/static6/img/icon/database_gear.png';
     }
     $classesList = new Object\ClassDefinition\Listing();
     $classesList->setOrderKey("name");
     $classesList->setOrder("asc");
     $classes = $classesList->load();
     // filter classes
     if ($this->getParam("createAllowed")) {
         $tmpClasses = [];
         foreach ($classes as $class) {
             if ($this->getUser()->isAllowed($class->getId(), "class")) {
                 $tmpClasses[] = $class;
             }
         }
         $classes = $tmpClasses;
     }
     $getClassConfig = function ($class) use($defaultIcon) {
         return ["id" => $class->getId(), "text" => $class->getName(), "leaf" => true, "icon" => $class->getIcon() ? $class->getIcon() : $defaultIcon, "propertyVisibility" => $class->getPropertyVisibility(), "qtipCfg" => ["title" => "ID: " . $class->getId()]];
     };
     // build groups
     $groups = [];
     foreach ($classes as $class) {
         if ($class->getGroup()) {
             $type = "manual";
             $groupName = $class->getGroup();
         } else {
             $type = "auto";
             preg_match("@^([A-Za-z])([^A-Z]+)@", $class->getName(), $matches);
             $groupName = $matches[0];
         }
         $groupName = \Pimcore\Model\Translation\Admin::getByKeyLocalized($groupName, true, true);
         if (!isset($groups[$groupName])) {
             $groups[$groupName] = ["classes" => [], "type" => $type];
         }
         $groups[$groupName]["classes"][] = $class;
     }
     $treeNodes = [];
     if (!$this->getParam('grouped')) {
         // list output
         foreach ($groups as $groupName => $groupData) {
             foreach ($groupData["classes"] as $class) {
                 $node = $getClassConfig($class);
                 if (count($groupData["classes"]) > 1 || $groupData["type"] == "manual") {
                     $node["group"] = $groupName;
                 }
                 $treeNodes[] = $node;
             }
         }
     } else {
         // create json output
         foreach ($groups as $groupName => $groupData) {
             if (count($groupData["classes"]) === 1 && $groupData["type"] == "auto") {
                 // no group, only one child
                 $node = $getClassConfig($groupData["classes"][0]);
             } else {
                 // group classes
                 $node = ["id" => "folder_" . $groupName, "text" => $groupName, "leaf" => false, 'expandable' => true, 'allowChildren' => true, 'iconCls' => 'pimcore_icon_folder', "children" => []];
                 foreach ($groupData["classes"] as $class) {
                     $node['children'][] = $getClassConfig($class);
                 }
             }
             $treeNodes[] = $node;
         }
     }
     $this->_helper->json($treeNodes);
 }