You are here

public function ParagraphsType::postSave in Paragraphs 8

Acts on a saved entity before the insert or update hook is invoked.

Used after the entity is saved, but before invoking the insert or update hook. Note that in case of translatable content entities this callback is only fired on their current translation. It is up to the developer to iterate over all translations if needed.

Parameters

\Drupal\Core\Entity\EntityStorageInterface $storage: The entity storage object.

bool $update: TRUE if the entity has been updated, or FALSE if it has been inserted.

Overrides ConfigEntityBundleBase::postSave

File

src/Entity/ParagraphsType.php, line 273

Class

ParagraphsType
Defines the ParagraphsType entity.

Namespace

Drupal\paragraphs\Entity

Code

public function postSave(EntityStorageInterface $storage, $update = TRUE) {
  if (!$update || $this->icon_uuid != $this->original->icon_uuid) {

    // Update the file usage for the icon file.
    $new_icon_file = $this->icon_uuid ? $this
      ->getFileByUuid($this->icon_uuid) : FALSE;

    // Update the file usage of the old icon as well if the icon was changed.
    $old_icon_file = $update && $this->original->icon_uuid ? $this
      ->getFileByUuid($this->original->icon_uuid) : FALSE;
    $this
      ->updateFileIconUsage($new_icon_file, $old_icon_file);
  }
  parent::postSave($storage, $update);
}