Ejemplo n.º 1
0
 /**
  * {@inheritdoc}
  */
 public function postSave(EntityStorageInterface $storage, $update = TRUE)
 {
     parent::postSave($storage, $update);
     // Only change the parents if a value is set, keep the existing values if
     // not.
     if (isset($this->parent->target_id)) {
         $storage->deleteTermHierarchy(array($this->id()));
         $storage->updateTermHierarchy($this);
     }
 }
Ejemplo n.º 2
0
 /**
  * {@inheritdoc}
  */
 public function postSave(EntityStorageInterface $storage, $update = TRUE)
 {
     parent::postSave($storage, $update);
     // If no order number has been set explicitly, set it to the order id.
     if (!$this->getOrderNumber()) {
         $this->setOrderNumber($this->id());
         $this->save();
     }
     // Ensure there's a back-reference on each line item.
     foreach ($this->getLineItems() as $line_item) {
         if ($line_item->order_id->isEmpty()) {
             $line_item->order_id = $this->id();
             $line_item->save();
         }
     }
 }
Ejemplo n.º 3
0
Archivo: Node.php Proyecto: brstde/gap1
 /**
  * {@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()) {
         \Drupal::entityManager()->getAccessControlHandler('node')->writeGrants($this, $update);
     }
     // Reindex the node when it is updated. The node is automatically indexed
     // when it is added, simply by being added to the node table.
     if ($update) {
         node_reindex_node_search($this->id());
     }
 }
Ejemplo n.º 4
0
 /**
  * {@inheritdoc}
  */
 public function postSave(EntityStorageInterface $storage, $update = TRUE)
 {
     parent::postSave($storage, $update);
     // Copy values for shared fields to existing user.
     if (\Drupal::config('simplenews.settings')->get('subscriber.sync_fields') && ($user = $this->getUser())) {
         static::$syncing = TRUE;
         foreach ($this->getUserSharedFields($user) as $field_name) {
             $user->set($field_name, $this->get($field_name)->getValue());
         }
         $user->save();
         static::$syncing = FALSE;
     }
 }
Ejemplo n.º 5
0
 /**
  * {@inheritdoc}
  */
 public function postSave(EntityStorageInterface $storage, $update = TRUE)
 {
     parent::postSave($storage, $update);
     $this->releaseThreadLock();
     // Update the {comment_entity_statistics} table prior to executing the hook.
     \Drupal::service('comment.statistics')->update($this);
 }
Ejemplo n.º 6
0
 /**
  * {@inheritdoc}
  */
 public function postSave(EntityStorageInterface $storage, $update = TRUE)
 {
     parent::postSave($storage, $update);
     // Entity::postSave() calls Entity::invalidateTagsOnSave(), which only
     // handles the regular cases. The Shortcut entity has one special case: a
     // newly created shortcut is *also* added to a shortcut set, so we must
     // invalidate the associated shortcut set's cache tag.
     if (!$update) {
         Cache::invalidateTags($this->getCacheTag());
     }
 }
Ejemplo n.º 7
0
 /**
  * {@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);
 }
Ejemplo n.º 8
0
 /**
  * {@inheritdoc}
  */
 public function postSave(EntityStorageInterface $storage, $update = TRUE)
 {
     parent::postSave($storage, $update);
     // Reindex the support_ticket when it is updated. The support_ticket is
     // automatically indexed when it is added, simply by being added to the
     // support_ticket table.
     if ($update) {
         // @todo
         // support_ticket_reindex_support_ticket_search($this->id());
     }
 }
Ejemplo n.º 9
0
 /**
  * {@inheritdoc}
  */
 public function postSave(EntityStorageInterface $storage, $update = TRUE)
 {
     parent::postSave($storage, $update);
     // Entity::postSave() calls Entity::invalidateTagsOnSave(), which only
     // handles the regular cases. The Item entity has one special case: a newly
     // created Item is *also* associated with a Feed, so we must invalidate the
     // associated Feed's cache tag.
     if (!$update) {
         Cache::invalidateTags($this->getCacheTagsToInvalidate());
     }
 }
Ejemplo n.º 10
0
 /**
  * {@inheritdoc}
  */
 public function postSave(EntityStorageInterface $storage, $update = TRUE)
 {
     parent::postSave($storage, $update);
     // If this is not a refresh token then create one.
     if (!$this->isRefreshToken()) {
         $this->addRefreshToken();
     }
     // If there is an access token for those conditions (resource + user) then
     // delete it.
     if (!$this->isNew() && $this->isDuplicated()) {
         $this->deleteDuplicates();
     }
 }
Ejemplo n.º 11
0
 /**
  * {@inheritdoc}
  */
 public function postSave(EntityStorageInterface $storage, $update = TRUE)
 {
     parent::postSave($storage, $update);
     foreach ($this->identities_unsaved as $k => $identity) {
         $registrant = Registrant::create(['registration' => $this])->setIdentity($identity);
         $registrant->save();
         unset($this->identities_unsaved[$k]);
     }
     $trigger_id = $update ? 'entity:registration:update' : 'entity:registration:new';
     \Drupal::service('rng.event_manager')->getMeta($this->getEvent())->trigger($trigger_id, ['registrations' => [$this]]);
 }
Ejemplo n.º 12
0
 /**
  * {@inheritdoc}
  */
 public function postSave(EntityStorageInterface $storage, $update = TRUE)
 {
     parent::postSave($storage, $update);
     /** @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 an menu link entry
     // on both entity and menu link plugin level.
     $definition = $this->getPluginDefinition();
     // Even when $update is FALSE, for top level links it is possible the link
     // already is in the storage because of the getPluginDefinition() call
     // above, see https://www.drupal.org/node/2605684#comment-10515450 for the
     // call chain. Because of this the $update flag is ignored and only the
     // existence of the definition (equals to being in the tree storage) is
     // checked.
     if ($menu_link_manager->getDefinition($this->getPluginId(), FALSE)) {
         // When the entity is saved via a plugin instance, we should not call
         // the menu tree manager to update the definition a second time.
         if (!$this->insidePlugin) {
             $menu_link_manager->updateDefinition($this->getPluginId(), $definition, FALSE);
         }
     } else {
         $menu_link_manager->addDefinition($this->getPluginId(), $definition);
     }
 }
Ejemplo n.º 13
0
 /**
  * {@inheritdoc}
  */
 public function postSave(EntityStorageInterface $storage, $update = TRUE)
 {
     /** @var \Drupal\profile\ProfileStorage $storage */
     parent::postSave($storage, $update);
     // Check if this profile is, or became the default.
     if ($this->isDefault()) {
         /** @var \Drupal\profile\Entity\ProfileInterface[] $profiles */
         $profiles = $storage->loadMultipleByUser($this->getOwner(), $this->getType());
         // Ensure that all other profiles are set to not default.
         foreach ($profiles as $profile) {
             if ($profile->id() != $this->id()) {
                 $profile->setDefault(FALSE);
                 $profile->save();
             }
         }
     }
 }
Ejemplo n.º 14
0
 /**
  * {@inheritdoc}
  */
 public function postSave(EntityStorageInterface $storage, $update = TRUE)
 {
     parent::postSave($storage, $update);
     static::invalidateBlockPluginCache();
 }
Ejemplo n.º 15
0
 /**
  * {@inheritdoc}
  */
 public function postSave(EntityStorageInterface $storage, $update = TRUE)
 {
     parent::postSave($storage, $update);
     foreach ($this->products as $product) {
         \Drupal::moduleHandler()->alter('uc_order_product', $product, $this);
         uc_order_product_save($this->id(), $product);
     }
     // Record a log entry if the order status has changed.
     if ($update && $this->getStatusId() != $this->original->getStatusId()) {
         $this->logChanges([(string) t('Order status') => ['old' => $this->original->getStatus()->getName(), 'new' => $this->getStatus()->getName()]]);
         // rules_invoke_event('uc_order_status_update', $this->original, $this);
     }
 }
Ejemplo n.º 16
0
 /**
  * {@inheritdoc}
  */
 public function postSave(EntityStorageInterface $storage, $update = TRUE)
 {
     parent::postSave($storage, $update);
     /** @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 an menu link entry
     // on both entity and menu link plugin level.
     if ($update && $menu_link_manager->getDefinition($this->getPluginId())) {
         // When the entity is saved via a plugin instance, we should not call
         // the menu tree manager to update the definition a second time.
         if (!$this->insidePlugin) {
             $menu_link_manager->updateDefinition($this->getPluginId(), $this->getPluginDefinition(), FALSE);
         }
     } else {
         $menu_link_manager->addDefinition($this->getPluginId(), $this->getPluginDefinition());
     }
 }
Ejemplo n.º 17
0
 /**
  * {@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();
             }
         }
         // If the user was blocked, delete the user's sessions to force a logout.
         if ($this->original->status->value != $this->status->value && $this->status->value == 0) {
             $session_manager->delete($this->id());
         }
         // Send emails after we have the new user object.
         if ($this->status->value != $this->original->status->value) {
             // The user's status is changing; conditionally send notification email.
             $op = $this->status->value == 1 ? 'status_activated' : 'status_blocked';
             _user_mail_notify($op, $this);
         }
     }
 }
Ejemplo n.º 18
0
 /**
  * {@inheritdoc}
  */
 public function postSave(EntityStorageInterface $storage, $update = TRUE)
 {
     parent::postSave($storage, $update);
     // Ensure there's a back-reference on each product variation.
     foreach ($this->variations as $item) {
         $variation = $item->entity;
         if ($variation->product_id->isEmpty()) {
             $variation->product_id = $this->id();
             $variation->save();
         }
     }
 }
Ejemplo n.º 19
0
 /**
  * {@inheritdoc}
  */
 public function postSave(EntityStorageInterface $storage, $update = TRUE)
 {
     parent::postSave($storage, $update);
     // Invalidate the block cache to update custom block-based derivatives.
     \Drupal::service('plugin.manager.block')->clearCachedDefinitions();
 }
Ejemplo n.º 20
0
 /**
  * {@inheritdoc}
  */
 public function postSave(EntityStorageInterface $storage, $update = TRUE)
 {
     parent::postSave($storage, $update);
     foreach ($this->components_unsaved as $k => $component) {
         $component->setRule($this)->save();
         unset($this->components_unsaved[$k]);
     }
 }