getRootClass()->getInstances(true); /** @var \core_kernel_classes_Resource $mediaInstance */ $report = Report::createSuccess(__('%s media on this environment', count($mediaInstances))); $count = 0; $success = 0; $dryrun = (isset($params[0]) && strpos($params[0], 'wetrun') !== false) ? false : true; foreach ($mediaInstances as $mediaInstance) { $link = $mediaInstance->getUniquePropertyValue(new \core_kernel_classes_Property(MediaService::PROPERTY_LINK)); if ($link instanceof \core_kernel_classes_Resource) { $count++; $filename = $link->getUniquePropertyValue(new \core_kernel_classes_Property(GenerisRdf::PROPERTY_FILE_FILENAME)); $filename = $filename instanceof \core_kernel_classes_Resource ? $filename->getUri() : (string)$filename; if (!$dryrun) { if ($mediaInstance->editPropertyValues(new \core_kernel_classes_Property(MediaService::PROPERTY_LINK), $filename)) { $success++; } else { $report->add(Report::createFailure(__('Issue while modifying %s', $mediaInstance->getUri()))); } } } } $report->add(Report::createSuccess(__('%s media to modify', $count))); if (!$dryrun) { $report->add(Report::createSuccess(__('%s media successfully modified', $success))); } return $report; } }