Exemplo n.º 1
0
 public function testUnsetInArrayByValueWithoutReindex()
 {
     $newArray = json_decode('[
       "__APPEND__",
         {
            "name":"populating",
            "label":"Populating",
            "view":"Advanced:TargetList.Record.Panels.Populating"
         }
     ]', true);
     $result = json_decode('{
       "1": {
         "name": "populating",
         "label": "Populating",
         "view": "Advanced:TargetList.Record.Panels.Populating"
       }
     }', true);
     $this->assertEquals($result, Util::unsetInArrayByValue('__APPEND__', $newArray, false));
 }
Exemplo n.º 2
0
 /**
  * Unset some fields and other stuff in metadat
  *
  * @param  string $key1
  * @param  string $key2
  * @param  array | string $unsets Ex. 'fields.name'
  *
  * @return bool
  */
 public function delete($key1, $key2, $unsets)
 {
     if (!is_array($unsets)) {
         $unsets = (array) $unsets;
     }
     $normalizedData = array('__APPEND__');
     $metaUnsetData = array();
     foreach ($unsets as $unsetItem) {
         $normalizedData[] = $unsetItem;
         $metaUnsetData[] = implode('.', array($key1, $key2, $unsetItem));
     }
     $unsetData = array($key1 => array($key2 => $normalizedData));
     $this->deletedData = Util::merge($this->deletedData, $unsetData);
     $this->deletedData = Util::unsetInArrayByValue('__APPEND__', $this->deletedData);
     $this->meta = Util::unsetInArray($this->getData(), $metaUnsetData);
 }