65 public function getUrl(
string $view,
string $subview =
''): string {
67 if (($view ===
'js' || $view ===
'css') && str_starts_with($subview, $view .
'/')) {
73 if (!empty($subview)) {
74 $view =
"{$view}/{$subview}";
80 $this->views->registerCacheableView($view);
93 $lastcache = (int) $this->config->lastcache;
107 return (
bool) $this->config->simplecache_enabled;
117 $this->config->save(
'simplecache_enabled', 1);
131 $this->config->save(
'simplecache_enabled', 0);
140 return (
string) $this->config->assetroot;
161 $lastcache = (int) $this->config->lastcache;
167 $di = new \DirectoryIterator($this->
getPath());
170 foreach ($di as $file_info) {
171 if (!$file_info->isDir() || $file_info->isDot()) {
175 if ((
int) $file_info->getBasename() === $lastcache) {
233 mkdir($dir, 0775,
true);
252 if (!isset($cache_time)) {
253 $cache_time = $this->config->lastcache;
getCacheFilename(string $viewtype, string $view, int $cache_time=null)
Get the cache file location.
__construct(Config $config, ViewsService $views)
Constructor.
cachedAssetExists(int $cache_time, string $viewtype, string $view)
Check if a asset exists in the cache.
if(!$enabled) if(PHP_SAPI!== 'cli')
clear()
Deletes all cached views in the simplecache.
purge()
Purge old/stale cache content.
isEnabled()
Is simple cache enabled.
disable()
Disables the simple cache.
getRoot()
Get the base url for simple cache requests.
enable()
Enables the simple cache.
if(!empty($avatar)&&!$avatar->isValid()) elseif(empty($avatar)) if(!$owner->saveIconFromUploadedFile('avatar')) if(!elgg_trigger_event('profileiconupdate', $owner->type, $owner)) $view
static canonicalizeViewName(string $alias)
Takes a view name and returns the canonical name for that view.
getCachedAssetLocation(int $cache_time, string $viewtype, string $view)
Get the cache location of an existing cached asset.
cacheAsset(string $viewtype, string $view, string $contents)
Store an asset for caching.
elgg_delete_directory(string $directory, bool $leave_base_directory=false)
Delete a directory and all its contents.
getPath()
Returns the path to where views are simplecached.
static sanitize($path, $append_slash=true)
Sanitize file paths ensuring that they begin and end with slashes etc.
elgg_normalize_url(string $url)
getUrl(string $view, string $subview= '')
Get the URL for the cached view.
if(!empty($title)&&!empty($icon_name)) if(!empty($title)) if(!empty($menu)) if(!empty($header)) if(!empty($body)) $contents