Pimcore\Model\Object\Data\KeyValue::setProperties PHP Метод

setProperties() публичный Метод

public setProperties ( $arr )
$arr
    public function setProperties($arr)
    {
        $newProperties = [];
        foreach ($arr as $key => $pair) {
            if (!$pair["inherited"]) {
                $newProperties[] = $pair;
            }
        }
        $this->arr = $newProperties;
        return $this;
    }

Usage Example

Пример #1
0
 /**
  * @param mixed $value
  * @param null $relatedObject
  * @param mixed $params
  * @param null $idMapper
  * @return mixed|Object\Data\KeyValue
  * @throws \Exception
  */
 public function getFromWebserviceImport($value, $relatedObject = null, $params = [], $idMapper = null)
 {
     if ($value) {
         $pairs = [];
         foreach ($value as $property) {
             if (array_key_exists("id", $property)) {
                 $property = (array) $property;
                 $id = $property["id"];
                 $property["key"] = $id;
                 unset($property["id"]);
                 $key = $property["key"];
                 if ($idMapper != null) {
                     $newKey = $idMapper->getMappedId("kvkey", $key);
                     if (!$newKey) {
                         if ($idMapper->ignoreMappingFailures()) {
                             $idMapper->recordMappingFailure("object", $relatedObject->getId(), "kvkey", $key);
                             continue;
                         } else {
                             throw new \Exception("Key " . $key . " could not be mapped");
                         }
                     }
                     $property["key"] = $newKey;
                 }
                 $pairs[] = $property;
             }
         }
         $keyValueData = new Object\Data\KeyValue();
         $keyValueData->setProperties($pairs);
         $keyValueData->setClass($relatedObject->getClass());
         $keyValueData->setObjectId($relatedObject->getId());
         return $keyValueData;
     }
 }