func = $func; } /** * Determine if the content has been fetched. * * @return bool */ public function isLoaded() { return $this->cache !== NULL; } public function load($force = FALSE) { if ($this->cache === NULL || $force) { $this->cache = CRM_Utils_Array::cast(call_user_func($this->func)); } return $this; } public function offsetExists($offset) { return isset($this->load()->cache[$offset]); } public function &offsetGet($offset) { return $this->load()->cache[$offset]; } public function offsetSet($offset, $value) { if ($offset === NULL) { $this->load()->cache[] = $value; } else { $this->load()->cache[$offset] = $value; } } public function offsetUnset($offset) { unset($this->load()->cache[$offset]); } public function getIterator() { return new ArrayIterator($this->load()->cache); } /** * @return array */ public function getArrayCopy() { return $this->load()->cache; } public function count() { return count($this->load()->cache); } }