32 $original_attributes =
$entity->getOriginalAttributes();
33 if (empty($original_attributes[
'owner_guid'])) {
37 $previous_owner_guid = $original_attributes[
'owner_guid'];
38 $new_owner_guid =
$entity->owner_guid;
41 foreach ($sizes as
$size) {
44 if ($new_icon->owner_guid ==
$entity->guid) {
49 if ($new_icon->owner_guid != $new_owner_guid) {
54 $old_icon = new \ElggIcon();
55 $old_icon->owner_guid = $previous_owner_guid;
56 $old_icon->setFilename($new_icon->getFilename());
57 if (!$old_icon->exists()) {
62 if ($new_icon->exists()) {
66 elgg_log(
"Entity $entity->guid has been transferred to a new owner but an icon was " 67 .
"left behind under {$old_icon->getFilenameOnFilestore()}. " 68 .
"Old icon has been deleted",
'NOTICE');
72 $old_icon->transfer($new_icon->owner_guid, $new_icon->getFilename());
73 elgg_log(
"Entity $entity->guid has been transferred to a new owner. " 74 .
"Icon was moved from {$old_icon->getFilenameOnFilestore()} to {$new_icon->getFilenameOnFilestore()}.",
'NOTICE');
elgg_get_icon_sizes($entity_type=null, $entity_subtype=null, $type= 'icon')
Returns a configuration array of icon sizes.
__invoke(\Elgg\Event $event)
Listen to entity ownership changes and update icon ownership by moving icons to their new owner's dir...
elgg_log($message, $level=\Psr\Log\LogLevel::NOTICE)
Log a message.
Models an event passed to event handlers.
Moves icons on ownership changes.
_elgg_services()
Get the global service provider.