本文整理汇总了PHP中Drupal\Core\Entity\ContentEntityBase::postSave方法的典型用法代码示例。如果您正苦于以下问题:PHP ContentEntityBase::postSave方法的具体用法?PHP ContentEntityBase::postSave怎么用?PHP ContentEntityBase::postSave使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Drupal\Core\Entity\ContentEntityBase
的用法示例。
在下文中一共展示了ContentEntityBase::postSave方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: postSave
/**
* {@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);
}
}
示例2: postSave
/**
* {@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();
}
}
}
示例3: postSave
/**
* {@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());
}
}
示例4: postSave
/**
* {@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;
}
}
示例5: postSave
/**
* {@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);
}
示例6: postSave
/**
* {@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());
}
}
示例7: postSave
/**
* {@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);
}
示例8: postSave
/**
* {@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());
}
}
示例9: postSave
/**
* {@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());
}
}
示例10: postSave
/**
* {@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();
}
}
示例11: postSave
/**
* {@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]]);
}
示例12: postSave
/**
* {@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);
}
}
示例13: postSave
/**
* {@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();
}
}
}
}
示例14: postSave
/**
* {@inheritdoc}
*/
public function postSave(EntityStorageInterface $storage, $update = TRUE)
{
parent::postSave($storage, $update);
static::invalidateBlockPluginCache();
}
示例15: postSave
/**
* {@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);
}
}