/** * Remvoe a given I2CE_FieldContainer from the cache * @param I2CE_FieldContainer $containerObj */ public function removeFromCache($containerObj) { if (!$containerObj instanceof I2CE_FieldContainer) { return; } if (($id = $containerObj->getId()) === '0') { return; } $name = $containerObj->getName(); if (!array_key_exists($name, $this->containerCache) || !is_array($this->containerCache[$name])) { return; } if ($id == '0') { if (!array_key_exists('0', $this->containerCache[$name])) { return; } foreach ($this->containerCache[$name]['0'] as $i => $cObj) { if ($cObj === $containerObj) { //these are the same objects unset($this->containerCache[$name]['0'][$i]); break; } } } else { if (!array_key_exists($id, $this->containerCache[$name]) && array_key_exists('0', $this->containerCache[$name]) && is_array($this->containerCache[$name]['0'])) { foreach ($this->containerCache[$name]['0'] as $i => $cObj) { if ($cObj === $containerObj) { //these are the same objects. started as anonymous then got saved unset($this->containerCache[$name]['0'][$i]); break; } } return; } unset($this->containerCache[$name][$id]); } }