Elgg  Version 4.3
TouchIconsOnAccessChangeHandler.php
Go to the documentation of this file.
1 <?php
2 
3 namespace Elgg\Icons;
4 
11 
19  public function __invoke(\Elgg\Event $event) {
20  $entity = $event->getObject();
21  if (!$entity instanceof \ElggEntity) {
22  return;
23  }
24 
25  $original_attributes = $entity->getOriginalAttributes();
26  if (!array_key_exists('access_id', $original_attributes)) {
27  return;
28  }
29 
30  if ($entity instanceof \ElggFile) {
31  // we touch the file to invalidate any previously generated download URLs
32  $entity->setModifiedTime();
33  }
34 
35  $sizes = array_keys(elgg_get_icon_sizes($entity->getType(), $entity->getSubtype()));
36  foreach ($sizes as $size) {
37  // using the Icon Service because we don't want to auto generate the 'new' icon
38  $icon = _elgg_services()->iconService->getIcon($entity, $size, 'icon', false);
39  if (!$icon->exists()) {
40  continue;
41  }
42 
43  $icon->setModifiedTime();
44  }
45  }
46 }
elgg_get_icon_sizes($entity_type=null, $entity_subtype=null, $type= 'icon')
Returns a configuration array of icon sizes.
__invoke(\Elgg\Event $event)
Reset icon URLs if access_id has changed.
if(function_exists('apache_get_version')) $icon
Definition: generic.php:49
$entity
Definition: reset.php:8
Models an event passed to event handlers.
Definition: Event.php:11
$size
Definition: thumb.php:23
_elgg_services()
Get the global service provider.
Definition: elgglib.php:638