ElggFileCache::delete PHP Method

delete() public method

Invalidate a given key.
public delete ( string $key ) : boolean
$key string Name
return boolean
    public function delete($key)
    {
        $dir = $this->getVariable("cache_path");
        if (file_exists($dir . $key)) {
            return unlink($dir . $key);
        }
        return true;
    }

Usage Example

Example #1
0
 /**
  * Initialize the site including site entity, plugins, and configuration
  *
  * @param array $submissionVars Submitted vars
  *
  * @return bool
  */
 protected function saveSiteSettings($submissionVars)
 {
     global $CONFIG;
     // ensure that file path, data path, and www root end in /
     $submissionVars['path'] = sanitise_filepath($submissionVars['path']);
     $submissionVars['dataroot'] = sanitise_filepath($submissionVars['dataroot']);
     $submissionVars['wwwroot'] = sanitise_filepath($submissionVars['wwwroot']);
     $site = new ElggSite();
     $site->name = $submissionVars['sitename'];
     $site->url = $submissionVars['wwwroot'];
     $site->access_id = ACCESS_PUBLIC;
     $site->email = $submissionVars['siteemail'];
     $guid = $site->save();
     if (!$guid) {
         register_error(elgg_echo('install:error:createsite'));
         return FALSE;
     }
     // bootstrap site info
     $CONFIG->site_guid = $guid;
     $CONFIG->site = $site;
     datalist_set('installed', time());
     datalist_set('path', $submissionVars['path']);
     datalist_set('dataroot', $submissionVars['dataroot']);
     datalist_set('default_site', $site->getGUID());
     datalist_set('version', get_version());
     datalist_set('simplecache_enabled', 1);
     datalist_set('viewpath_cache_enabled', 1);
     // new installations have run all the upgrades
     $upgrades = elgg_get_upgrade_files($submissionVars['path'] . 'engine/lib/upgrades/');
     datalist_set('processed_upgrades', serialize($upgrades));
     set_config('view', 'default', $site->getGUID());
     set_config('language', 'en', $site->getGUID());
     set_config('default_access', $submissionVars['siteaccess'], $site->getGUID());
     set_config('allow_registration', TRUE, $site->getGUID());
     set_config('walled_garden', FALSE, $site->getGUID());
     $this->enablePlugins();
     // reset the views path in case of installing over an old data dir.
     $dataroot = $submissionVars['dataroot'];
     $CONFIG->dataroot = $dataroot;
     $cache = new ElggFileCache($dataroot);
     $cache->delete('view_paths');
     return TRUE;
 }
All Usage Examples Of ElggFileCache::delete