/** * Fetch a collection of replace fields * @param array $arr_where - Optional * @param boolean $use_cache - Optional. Defaults to FALSE * @return StdClass */ public function fetchReplaceFields($arr_where = array(), $use_cache = FALSE) { //check if data is cached $this->objCache = $this->getServiceLocator()->get("FrontCore\\Caches\\Cache"); if ($use_cache == TRUE && $this->objCache->readCacheItem($this->cache_key) != FALSE) { return $this->objCache->readCacheItem($this->cache_key); } //end if //create the request object $objApiRequest = $this->getApiRequestModel(); //setup the object and specify the action $objApiRequest->setApiAction("forms/fields/replace"); //execute $objFields = $objApiRequest->performGETRequest($arr_where)->getBody(); //save data to cache $this->objCache->setCacheItem($this->cache_key, $objFields->data, array("ttl" => 3600)); return $objFields->data; }
/** * Save data to disk * @param unknown $arr_data */ private function saveFile($arr_data) { $r = $this->setPath(); if (!$r) { return $r; } //end if $arr_settings = (array) $this->readFile(); $arr_settings = array_merge($arr_settings, $arr_data); $objData = json_encode($arr_settings, JSON_FORCE_OBJECT); file_put_contents($this->path, $objData); //save to cache $this->objCache->setCacheItem($this->cache_key, $objData, array("ttl" => 5 * 60)); }