You are here

public function EckEntityBundle::postSave in Entity Construction Kit (ECK) 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/EckEntityBundle.php, line 98

Class

EckEntityBundle
Defines the ECK entity bundle configuration entity.

Namespace

Drupal\eck\Entity

Code

public function postSave(EntityStorageInterface $storage, $update = TRUE) {
  parent::postSave($storage, $update);

  // Update workflow options.
  // @todo Make it possible to get default values without an entity.
  //   https://www.drupal.org/node/2318187
  $eckEntityStorage = \Drupal::entityTypeManager()
    ->getStorage($this
    ->getEckEntityTypeMachineName());
  $eckEntityStorage
    ->create([
    'type' => $this
      ->id(),
  ]);
  \Drupal::service('entity_field.manager')
    ->clearCachedFieldDefinitions();

  // Clear all caches because the action links need to be regenerated.
  // @todo figure out how to do this without clearing ALL caches.
  drupal_flush_all_caches();
}