public function transferIcons(\ElggGroup $group, \Elgg\Upgrade\Result $result)
{
$sizes = elgg_get_icon_sizes('group', $group->getSubtype());
$dataroot = elgg_get_config('dataroot');
$dir = (new \Elgg\EntityDirLocator($group->owner_guid))->getPath();
$prefix = 'groups/';
foreach ($sizes as $size => $opts) {
$filename = "{$group->guid}{$size}.jpg";
$filestorename = "{$dataroot}{$dir}{$prefix}{$filename}";
if (!file_exists($filestorename)) {
// nothing to move
continue;
}
$icon = $group->getIcon($size);
// before transferring the file, we need to make sure
// the directory structure of the new filestore location exists
$icon->open('write');
$icon->close();
if (!rename($filestorename, $icon->getFilenameOnFilestore())) {
$result->addError("\n\t\t\t\t\tFailed to transfer file from '{$filestorename}'\n\t\t\t\t\tto {$icon->getFilenameOnFilestore()}\n\t\t\t\t");
$error = true;
}
}
if ($error) {
$result->addFailures();
} else {
$result->addSuccesses();
}
return $result;
}