Elgg  Version 4.3
CalculateSRI.php
Go to the documentation of this file.
1 <?php
2 
3 namespace Elgg\Views;
4 
10 class CalculateSRI {
11 
19  public function __invoke(\Elgg\Hook $hook) {
20  $view = $hook->getParam('view');
21  if (empty($view)) {
22  return;
23  }
24 
25  $type = $hook->getType();
26 
27  $data = _elgg_services()->serverCache->load('sri') ?? [];
28  if (!isset($data[$type])) {
29  $data[$type] = [];
30  }
31 
32  if (isset($data[$type][$view])) {
33  return;
34  }
35 
36  $hash = base64_encode(hash('sha256', $hook->getValue(), true));
37  $data[$type][$view] = "sha256-{$hash}";
38  _elgg_services()->serverCache->save('sri', $data);
39  }
40 }
__invoke(\Elgg\Hook $hook)
Calculates the SRI of a simplecache resource file for future use.
if(elgg_trigger_plugin_hook('usersettings:save', 'user', $hooks_params, true)) foreach($request->validation() ->all() as $item) $data
Definition: save.php:53
$type
Definition: delete.php:21
Calculates SRI for simplecache resources.
Models an event passed to hook handlers.
Definition: Hook.php:11
if(!empty($avatar)&&!$avatar->isValid()) elseif(empty($avatar)) if(!$owner->saveIconFromUploadedFile('avatar')) if(!elgg_trigger_event('profileiconupdate', $owner->type, $owner)) $view
Definition: upload.php:39
_elgg_services()
Get the global service provider.
Definition: elgglib.php:638