getById() public static méthode

public static getById ( integer $id ) : KeyConfig
$id integer
Résultat KeyConfig
Exemple #1
0
 /**
  * Loads a list of keyvalue key configs for the specifies parameters, returns an array of config elements
  *
  * @return array
  */
 public function load()
 {
     $sql = "SELECT id FROM " . Object\KeyValue\KeyConfig\Dao::TABLE_NAME_KEYS . $this->getCondition() . $this->getOrder() . $this->getOffsetLimit();
     $configsData = $this->db->fetchCol($sql, $this->model->getConditionVariables());
     $configData = array();
     foreach ($configsData as $config) {
         $configData[] = Object\KeyValue\KeyConfig::getById($config);
     }
     $this->model->setList($configData);
     return $configData;
 }
Exemple #2
0
 /**
  * converts data to be exposed via webservices
  * @param string $object
  * @param mixed $params
  * @return mixed
  */
 public function getForWebserviceExport($object, $params = [])
 {
     $data = $this->getDataFromObjectParam($object, $params);
     if ($data) {
         $result = [];
         foreach ($data->arr as $item) {
             $keyConfig = Object\KeyValue\KeyConfig::getById($item["key"]);
             $keyName = $keyConfig->getName();
             $resultItem = ["id" => $item["key"], "name" => $keyName, "value" => $item["value"], "metadata" => $item["metadata"]];
             if ($keyConfig->getType() == "translated") {
                 $resultItem["translated"] = $item["translated"];
             }
             $result[] = $resultItem;
         }
         return $result;
     }
 }
 /**
  * @param $keyId
  * @param $value
  * @return string
  */
 private function getTranslatedValue($keyId, $value)
 {
     $translatedValue = "";
     $keyConfig = Object\KeyValue\KeyConfig::getById($keyId);
     $translatorID = $keyConfig->getTranslator();
     $translatorConfig = Object\KeyValue\TranslatorConfig::getById($translatorID);
     $className = $translatorConfig->getTranslator();
     if (\Pimcore\Tool::classExists($className)) {
         $translator = new $className();
         $translatedValue = $translator->translate($value);
         if (!$translatedValue) {
             $translatedValue = $value;
         }
     }
     return $translatedValue;
 }
 public function translateAction()
 {
     $success = false;
     $keyId = $this->getParam("keyId");
     $objectId = $this->getParam("objectId");
     $recordId = $this->getParam("recordId");
     $text = $this->getParam("text");
     $translatedValue = $text;
     try {
         $keyConfig = KeyValue\KeyConfig::getById($keyId);
         $translatorID = $keyConfig->getTranslator();
         $translatorConfig = KeyValue\TranslatorConfig::getById($translatorID);
         $className = $translatorConfig->getTranslator();
         if (\Pimcore\Tool::classExists($className)) {
             $translator = new $className();
             $translatedValue = $translator->translate($text);
             if (!$translatedValue) {
                 $translatedValue = $text;
             }
         }
         $this->_helper->json(["success" => true, "keyId" => $this->getParam("keyId"), "text" => $text, "translated" => $translatedValue, "recordId" => $recordId]);
     } catch (\Exception $e) {
     }
     $this->_helper->json(["success" => $success]);
 }