コード例 #1
0
 protected static function keyById(array $things, EarthIT_Schema_ResourceClass $rc = null)
 {
     $keyed = array();
     foreach ($things as $t) {
         $id = $rc === null ? $t['ID'] : EarthIT_Storage_Util::itemId($t, $rc);
         $keyed[$id] = $t;
     }
     return $keyed;
 }
コード例 #2
0
 public function updateItems(array $updatedFieldValues, EarthIT_Schema_ResourceClass $rc, EarthIT_Storage_ItemFilter $filter, array $options = array())
 {
     $rcName = $rc->getName();
     $matchedKeys = array();
     if (isset($this->items[$rcName])) {
         foreach ($this->items[$rcName] as $k => $item) {
             if ($filter->matches($item)) {
                 $matchedKeys[] = $k;
             }
         }
     }
     $updated = array();
     foreach ($matchedKeys as $k) {
         $item = $this->items[$rcName][$k];
         $item = $updatedFieldValues + $item;
         $id = EarthIT_Storage_Util::itemId($item, $rc);
         if ($id !== null and $id !== $k) {
             // TODO: Look at options to determine if updating is allowed
             // to overwrite other items
             unset($this->items[$rcName][$k]);
             $this->items[$rcName][$id] = $item;
             $k = $id;
         }
         $updated[$k] = $item;
     }
     return $updated;
 }