protected function ParagraphsType::updateFileIconUsage

Updates the icon file usage information.

Parameters

\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.

2 calls to ParagraphsType::updateFileIconUsage()
ParagraphsType::postSave in paragraphs/src/Entity/ParagraphsType.php
ParagraphsType::restoreDefaultIcon in paragraphs/src/Entity/ParagraphsType.php
Restores the icon file from the default icon value.

File

paragraphs/src/Entity/ParagraphsType.php, line 313

Class

ParagraphsType
Defines the ParagraphsType entity.

Namespace

Drupal\paragraphs\Entity

Code

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());
  }
}