postSave example

    // and \Drupal\comment\CommentForm::buildEntity() for name setting.     if (!$this->getOwner()->isAnonymous()) {
      $this->set('name', NULL);
      $this->set('mail', NULL);
    }
  }

  /** * {@inheritdoc} */
  public function postSave(EntityStorageInterface $storage$update = TRUE) {
    parent::postSave($storage$update);

    // Always invalidate the cache tag for the commented entity.     if ($commented_entity = $this->getCommentedEntity()) {
      Cache::invalidateTags($commented_entity->getCacheTagsToInvalidate());
    }

    $this->releaseThreadLock();
    // Update the {comment_entity_statistics} table prior to executing the hook.     \Drupal::service('comment.statistics')->update($this);
  }

  
    foreach (['user_cancel_method', 'user_cancel_notify'] as $key) {
      if (isset($this->{$key})) {
        \Drupal::service('user.data')->set('user', $this->id()substr($key, 5)$this->{$key});
      }
    }
  }

  /** * {@inheritdoc} */
  public function postSave(EntityStorageInterface $storage$update = TRUE) {
    parent::postSave($storage$update);

    if ($update) {
      $session_manager = \Drupal::service('session_manager');
      // If the password has been changed, delete all open sessions for the       // user and recreate the current one.       if ($this->pass->value != $this->original->pass->value) {
        $session_manager->delete($this->id());
        if ($this->id() == \Drupal::currentUser()->id()) {
          \Drupal::service('session')->migrate();
        }
      }

      

  protected function doPostSave(EntityInterface $entity$update) {
    $this->resetCache([$entity->id()]);

    // The entity is no longer new.     $entity->enforceIsNew(FALSE);

    // Allow code to run after saving.     $entity->postSave($this$update);
    $this->invokeHook($update ? 'update' : 'insert', $entity);

    // After saving, this is now the "original entity", and subsequent saves     // will be updates instead of inserts, and updates must always be able to     // correctly identify the original entity.     $entity->setOriginalId($entity->id());

    unset($entity->original);
  }

  /** * {@inheritdoc} */
$this->setRequiresRediscovery(TRUE);
    }
    else {
      $this->setRequiresRediscovery(FALSE);
    }
  }

  /** * {@inheritdoc} */
  public function postSave(EntityStorageInterface $storage$update = TRUE) {
    parent::postSave($storage$update);

    // Don't update the menu tree if a pending revision was saved.     if (!$this->isDefaultRevision()) {
      return;
    }

    /** @var \Drupal\Core\Menu\MenuLinkManagerInterface $menu_link_manager */
    $menu_link_manager = \Drupal::service('plugin.manager.menu.link');

    // The menu link can just be updated if there is already a menu link entry     // on both entity and menu link plugin level.

  protected function normalizeRestMethod($method) {
    return strtoupper($method);
  }

  /** * {@inheritdoc} */
  public function postSave(EntityStorageInterface $storage$update = TRUE) {
    parent::postSave($storage$update);

    \Drupal::service('router.builder')->setRebuildNeeded();
  }

  /** * {@inheritdoc} */
  public static function postDelete(EntityStorageInterface $storage, array $entities) {
    parent::postDelete($storage$entities);

    \Drupal::service('router.builder')->setRebuildNeeded();
  }
// List cache tag.           $this->entityTypeId . '_list',
          // Own cache tag.           $this->entityTypeId . ':' . $this->values['id'],
        ],
      ]);

    // This method is internal, so check for errors on calling it only.     $storage = $this->createMock('\Drupal\Core\Entity\EntityStorageInterface');

    // A creation should trigger the invalidation of the "list" cache tag.     $this->entity->postSave($storage, FALSE);
    // An update should trigger the invalidation of both the "list" and the     // "own" cache tags.     $this->entity->postSave($storage, TRUE);
  }

  /** * @covers ::postSave */
  public function testPostSaveBundle() {
    $this->cacheTagsInvalidator->expects($this->exactly(2))
      ->method('invalidateTags')
      
parent::preSave($storage);
    // Store whether or not the site is already multilingual so that we can     // rebuild services if necessary during     // \Drupal\language\Entity\ConfigurableLanguage::postSave().     $this->preSaveMultilingual = \Drupal::languageManager()->isMultilingual();
  }

  /** * {@inheritdoc} */
  public function postSave(EntityStorageInterface $storage$update = TRUE) {
    parent::postSave($storage$update);

    $language_manager = \Drupal::languageManager();
    $language_manager->reset();
    if (!$this->isLocked() && $language_manager instanceof ConfigurableLanguageManagerInterface && !$this->isSyncing()) {
      $language_manager->updateLockedLanguageWeights();
    }

    // Update URL Prefixes for all languages after the     // LanguageManagerInterface::getLanguages() cache is flushed.     language_negotiation_url_prefixes_update();

    
// If no thumbnail has been explicitly set, use the default thumbnail.     if ($this->get('thumbnail')->isEmpty()) {
      $this->thumbnail->target_id = $this->loadThumbnail()->id();
    }
  }

  /** * {@inheritdoc} */
  public function postSave(EntityStorageInterface $storage$update = TRUE) {
    parent::postSave($storage$update);
    $is_new = !$update;
    foreach ($this->translations as $langcode => $data) {
      if ($this->hasTranslation($langcode)) {
        $translation = $this->getTranslation($langcode);
        if ($translation->bundle->entity->thumbnailDownloadsAreQueued() && $translation->shouldUpdateThumbnail($is_new)) {
          \Drupal::queue('media_entity_thumbnail')->createItem(['id' => $translation->id()]);
        }
      }
    }
  }

  
/** * The human-readable name of the configuration entity. * * @var string */
  protected $label;

  /** * {@inheritdoc} */
  public function postSave(EntityStorageInterface $storage$update = TRUE) {
    parent::postSave($storage$update);

    if (!$update && !$this->isSyncing()) {
      // Save a new shortcut set with links copied from the user's default set.       $default_set = shortcut_default_set();
      // This is the default set, do not copy shortcuts.       if ($default_set->id() != $this->id()) {
        foreach ($default_set->getShortcuts() as $shortcut) {
          $shortcut = $shortcut->createDuplicate();
          $shortcut->enforceIsNew();
          $shortcut->shortcut_set->target_id = $this->id();
          $shortcut->save();
        }
/** * {@inheritdoc} */
  public function id() {
    return $this->name;
  }

  /** * {@inheritdoc} */
  public function postSave(EntityStorageInterface $storage$update = TRUE) {
    parent::postSave($storage$update);

    if ($update) {
      if (!empty($this->original) && $this->id() !== $this->original->id()) {
        // The old image style name needs flushing after a rename.         $this->original->flush();
        // Update field settings if necessary.         if (!$this->isSyncing()) {
          static::replaceImageStyle($this);
        }
      }
      else {
        
// Trim the alias value of whitespace and slashes. Ensure to not trim the     // slash on the left side.     $alias = rtrim(trim($this->getAlias()), "\\/");
    $this->setAlias($alias);
  }

  /** * {@inheritdoc} */
  public function postSave(EntityStorageInterface $storage$update = TRUE) {
    parent::postSave($storage$update);

    $alias_manager = \Drupal::service('path_alias.manager');
    $alias_manager->cacheClear($this->getPath());
    if ($update) {
      $alias_manager->cacheClear($this->original->getPath());
    }
  }

  /** * {@inheritdoc} */
  
      // need to make sure $entity->revision_log is reset whenever it is empty.       // Therefore, this code allows us to avoid clobbering an existing log       // entry with an empty one.       $record->revision_log = $this->original->revision_log->value;
    }
  }

  /** * {@inheritdoc} */
  public function postSave(EntityStorageInterface $storage$update = TRUE) {
    parent::postSave($storage$update);

    // Update the node access table for this node, but only if it is the     // default revision. There's no need to delete existing records if the node     // is new.     if ($this->isDefaultRevision()) {
      /** @var \Drupal\node\NodeAccessControlHandlerInterface $access_control_handler */
      $access_control_handler = \Drupal::entityTypeManager()->getAccessControlHandler('node');
      $grants = $access_control_handler->acquireGrants($this);
      \Drupal::service('node.grant_storage')->write($this$grants, NULL, $update);
    }

    
/** * {@inheritdoc} */
  public function preSaveRevision(EntityStorageInterface $storage, \stdClass $record) {
  }

  /** * {@inheritdoc} */
  public function postSave(EntityStorageInterface $storage$update = TRUE) {
    parent::postSave($storage$update);

    // Update the status of all saved translations.     $removed = [];
    foreach ($this->translations as $langcode => &$data) {
      if ($data['status'] == static::TRANSLATION_REMOVED) {
        $removed[$langcode] = TRUE;
      }
      else {
        $data['status'] = static::TRANSLATION_EXISTING;
      }
    }
    
/** * {@inheritdoc} */
  public function getDescription() {
    return $this->description;
  }

  /** * {@inheritdoc} */
  public function postSave(EntityStorageInterface $storage$update = TRUE) {
    parent::postSave($storage$update);

    if ($update && $this->getOriginalId() != $this->id()) {
      $update_count = $storage->updateType($this->getOriginalId()$this->id());
      if ($update_count) {
        \Drupal::messenger()->addStatus(\Drupal::translation()->formatPlural($update_count,
          'Changed the content type of 1 post from %old-type to %type.',
          'Changed the content type of @count posts from %old-type to %type.',
          [
            '%old-type' => $this->getOriginalId(),
            '%type' => $this->id(),
          ]));
      }
// @todo Use self::applyDefaultValue() once     // https://www.drupal.org/node/2004756 is in.     if (!isset($this->weight)) {
      $this->weight = $this->isDefaultSearch() ? -10 : 0;
    }
  }

  /** * {@inheritdoc} */
  public function postSave(EntityStorageInterface $storage$update = TRUE) {
    parent::postSave($storage$update);
    $this->routeBuilder()->setRebuildNeeded();
  }

  /** * {@inheritdoc} */
  public static function postDelete(EntityStorageInterface $storage, array $entities) {
    parent::postDelete($storage$entities);

    $search_page_repository = \Drupal::service('search.search_page_repository');
    if (!$search_page_repository->isSearchActive()) {
      
Home | Imprint | This part of the site doesn't use cookies.