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()) {
67 $notice =
"Entity {$entity->guid} has been transferred to a new owner but an icon was";
68 $notice .=
" left behind under {$old_icon->getFilenameOnFilestore()}.";
69 $notice .=
' Old icon has been deleted';
70 elgg_log($notice, \Psr\Log\LogLevel::NOTICE);
74 $old_icon->transfer($new_icon->owner_guid, $new_icon->getFilename());
76 $notice =
"Entity {$entity->guid} has been transferred to a new owner.";
77 $notice .=
" Icon was moved from {$old_icon->getFilenameOnFilestore()} to {$new_icon->getFilenameOnFilestore()}.";
78 elgg_log($notice, \Psr\Log\LogLevel::NOTICE);
elgg_get_icon_sizes(string $entity_type=null, string $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.
Moves icons on ownership changes.
_elgg_services()
Get the global service provider.
Models an event passed to event handlers.