Updates the icon file usage information.
\Drupal\file\FileInterface|mixed $new_icon: The new icon file, FALSE on deletion.
\Drupal\file\FileInterface|mixed $old_icon: (optional) Old icon, on update or deletion.
protected function updateFileIconUsage($new_icon, $old_icon = FALSE) {
/** @var \Drupal\file\FileUsage\FileUsageInterface $file_usage */
$file_usage = \Drupal::service('file.usage');
if ($new_icon) {
// Add usage of the new icon file.
$file_usage
->add($new_icon, 'paragraphs', 'paragraphs_type', $this
->id());
}
if ($old_icon) {
// Delete usage of the old icon file.
$file_usage
->delete($old_icon, 'paragraphs', 'paragraphs_type', $this
->id());
}
}