setName() public méthode

public setName ( string $name )
$name string
 public function addpropertyAction()
 {
     $name = $this->getParam("name");
     $alreadyExist = false;
     if (!$alreadyExist) {
         $config = new KeyValue\KeyConfig();
         $config->setName($name);
         $config->setType("text");
         $config->save();
     }
     $this->_helper->json(["success" => !$alreadyExist, "id" => $config->getName()]);
 }
Exemple #2
0
 /** Imports the group/key config from XML.
  * @param $config
  */
 public static function import($config)
 {
     if (is_array($config["groups"])) {
         $groups = $config["groups"]["group"];
         if (!isset($groups[0])) {
             $groups = array($groups);
         }
         $groupIdMapping = array();
         foreach ($groups as $groupConfig) {
             $name = $groupConfig["name"];
             $group = Object\KeyValue\GroupConfig::getByName($name);
             if (!$group) {
                 $group = new Object\KeyValue\GroupConfig();
                 $group->setName($name);
             }
             $group->setDescription($groupConfig["description"]);
             $group->save();
             // mapping of remote id to local id
             $groupIdMapping[$groupConfig["id"]] = $group->getId();
         }
     }
     if (is_array($config["keys"])) {
         $keys = $config["keys"]["key"];
         if (!isset($keys[0])) {
             $keys = array($keys);
         }
         foreach ($keys as $keyConfig) {
             $name = $keyConfig["name"];
             $key = Object\KeyValue\KeyConfig::getByName($name);
             if (!$key) {
                 $key = new Object\KeyValue\KeyConfig();
                 $key->setName($name);
             }
             $key->setDescription($keyConfig["description"]);
             $key->setType($keyConfig["type"]);
             if (!empty($keyConfig["unit"])) {
                 $key->setUnit($keyConfig["unit"]);
             }
             if (!empty($keyConfig["possiblevalues"])) {
                 $key->setPossibleValues($keyConfig["possiblevalues"]);
             }
             $originalGroupId = $keyConfig["group"];
             if (!empty($originalGroupId)) {
                 $mappedGroupId = $groupIdMapping[$originalGroupId];
                 $key->setGroup($mappedGroupId);
             }
             $key->save();
         }
     }
 }