本文整理汇总了PHP中Drupal\Core\Config\Entity\ConfigEntityBase::postSave方法的典型用法代码示例。如果您正苦于以下问题:PHP ConfigEntityBase::postSave方法的具体用法?PHP ConfigEntityBase::postSave怎么用?PHP ConfigEntityBase::postSave使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Drupal\Core\Config\Entity\ConfigEntityBase
的用法示例。
在下文中一共展示了ConfigEntityBase::postSave方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: postSave
/**
* {@inheritdoc}
*/
public function postSave(EntityStorageInterface $storage, $update = TRUE)
{
parent::postSave($storage, $update);
if (!$update) {
entity_invoke_bundle_hook('create', $this->getEntityType()->getBundleOf(), $this->id());
} elseif ($this->getOriginalId() != $this->id()) {
entity_invoke_bundle_hook('rename', $this->getEntityType()->getBundleOf(), $this->getOriginalId(), $this->id());
}
}
示例2: postSave
/**
* {@inheritdoc}
*/
public function postSave(EntityStorageInterface $storage, $update = TRUE)
{
parent::postSave($storage, $update);
if (!$update) {
$this->entityManager()->onBundleCreate($this->id(), $this->getEntityType()->getBundleOf());
} elseif ($this->getOriginalId() != $this->id()) {
$this->renameDisplays();
$this->entityManager()->onBundleRename($this->getOriginalId(), $this->id(), $this->getEntityType()->getBundleOf());
}
}
示例3: postSave
/**
* {@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();
}
}
}
}
示例4: postSave
/**
* {@inheritdoc}
*/
public function postSave(EntityStorageInterface $storage, $update = TRUE)
{
parent::postSave($storage, $update);
$entity_manager = $this->entityManager();
$bundle_of = $this->getEntityType()->getBundleOf();
if (!$update) {
$entity_manager->onBundleCreate($this->id(), $bundle_of);
} else {
// Invalidate the render cache of entities for which this entity
// is a bundle.
if ($entity_manager->hasHandler($bundle_of, 'view_builder')) {
$entity_manager->getViewBuilder($bundle_of)->resetCache();
}
// Entity bundle field definitions may depend on bundle settings.
$entity_manager->clearCachedFieldDefinitions();
}
}
示例5: postSave
/**
* {@inheritdoc}
*/
public function postSave(EntityStorageInterface $storage, $update = TRUE)
{
parent::postSave($storage, $update);
if (\Drupal::entityManager()->hasHandler($this->targetEntityType, 'view_builder')) {
\Drupal::entityManager()->getViewBuilder($this->targetEntityType)->resetCache();
}
}
示例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 Block entity has one special case: a
// newly created block may *also* appear on any page in the current theme,
// so we must invalidate the associated block's cache tag (which includes
// the theme cache tag).
if (!$update) {
Cache::invalidateTags($this->getCacheTagsToInvalidate());
}
}
示例7: postSave
/**
* {@inheritdoc}
*/
public function postSave(EntityStorageInterface $storage, $update = TRUE)
{
parent::postSave($storage, $update);
try {
// Fake an original for inserts to make code cleaner.
/** @var \Drupal\search_api\IndexInterface $original */
$original = $update ? $this->original : static::create(array('status' => FALSE));
$index_task_manager = \Drupal::getContainer()->get('search_api.index_task_manager');
if ($this->status() && $original->status()) {
// React on possible changes that would require re-indexing, etc.
$this->reactToServerSwitch($original);
$this->reactToDatasourceSwitch($original);
$this->reactToTrackerSwitch($original);
$this->reactToProcessorChanges($original);
} elseif (!$this->status() && $original->status()) {
if ($this->hasValidTracker()) {
$index_task_manager->stopTracking($this);
}
if ($original->isServerEnabled()) {
$original->getServerInstance()->removeIndex($this);
}
} elseif ($this->status() && !$original->status()) {
$this->getServerInstance()->addIndex($this);
if ($this->hasValidTracker()) {
$index_task_manager->startTracking($this);
}
}
if (!$index_task_manager->isTrackingComplete($this)) {
// Give tests and site admins the possibility to disable the use of a
// batch for tracking items. Also, do not use a batch if running in the
// CLI.
$use_batch = \Drupal::state()->get('search_api_use_tracking_batch', TRUE);
if (!$use_batch || php_sapi_name() == 'cli') {
$index_task_manager->addItemsAll($this);
} else {
$index_task_manager->addItemsBatch($this);
}
}
if (\Drupal::moduleHandler()->moduleExists('views')) {
Views::viewsData()->clear();
// Remove this line when https://www.drupal.org/node/2370365 gets fixed.
Cache::invalidateTags(array('extension:views'));
\Drupal::cache('discovery')->delete('views:wizard');
}
Cache::invalidateTags($this->getCacheTags());
} catch (SearchApiException $e) {
watchdog_exception('search_api', $e);
}
}
示例8: postSave
/**
* {@inheritdoc}
*/
public function postSave(EntityStorageInterface $storage, $update = TRUE) {
parent::postSave($storage, $update);
if ($update) {
if (!empty($this->original) && $this->id() !== $this->original->id()) {
// Update field settings if necessary.
if (!$this->isSyncing()) {
//static::replaceBlockTabs($this);
}
}
else {
}
}
}
示例9: postSave
/**
* {@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 after adding this language the site will become multilingual, we need
// to rebuild language services.
if (!$this->preSaveMultilingual && !$update && $language_manager instanceof ConfigurableLanguageManagerInterface) {
$language_manager::rebuildServices();
}
if (!$update) {
// Install any available language configuration overrides for the language.
\Drupal::service('language.config_factory_override')->installLanguageOverrides($this->id());
}
}
示例10: postSave
/**
* {@inheritdoc}
*/
public function postSave(EntityStorageInterface $storage, $update = TRUE)
{
parent::postSave($storage, $update);
// Only set the default language and save it to system.site configuration if
// it needs to updated.
if ($this->isDefault() && static::getDefaultLangcode() != $this->id()) {
// Update the config. Saving the configuration fires and event that causes
// the container to be rebuilt.
\Drupal::config('system.site')->set('langcode', $this->id())->save();
\Drupal::service('language.default')->set($this->toLanguageObject());
}
$language_manager = \Drupal::languageManager();
$language_manager->reset();
if ($language_manager instanceof ConfigurableLanguageManagerInterface) {
$language_manager->updateLockedLanguageWeights();
}
// Update URL Prefixes for all languages after the new default language is
// propagated and the LanguageManagerInterface::getLanguages() cache is
// flushed.
language_negotiation_url_prefixes_update();
// If after adding this language the site will become multilingual, we need
// to rebuild language services.
if (!$this->preSaveMultilingual && !$update && $language_manager instanceof ConfigurableLanguageManagerInterface) {
$language_manager::rebuildServices();
}
}
示例11: postSave
/**
* {@inheritdoc}
*/
public function postSave(EntityStorageInterface $storage, $update = TRUE)
{
parent::postSave($storage, $update);
// Clear render cache.
entity_render_cache_clear();
}
示例12: postSave
/**
* {@inheritdoc}
*/
public function postSave(EntityStorageInterface $storage, $update = TRUE)
{
parent::postSave($storage, $update);
$this->routeBuilderIndicator()->setRebuildNeeded();
}
示例13: postSave
/**
* {@inheritdoc}
*/
public function postSave(EntityStorageInterface $storage, $update = TRUE)
{
// Re-convert entity UUID route parameters back into IDs. This is important
// if the entity is used later in the same request.
/** @see static::preSave() */
$entity_manager = $this->entityManager();
$this->processEntityRouteParameters($this, function ($entity_type_id, $value) use($entity_manager) {
$entity = $entity_manager->loadEntityByUuid($entity_type_id, $value);
// Entity validation should have ensured that this entity in fact exists
// but we try to avoid incomprehensible fatals at all costs.
if ($entity instanceof EntityInterface) {
return $entity->id();
}
});
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())) {
$menu_link_manager->updateDefinition($this->getPluginId(), $this->getPluginDefinition(), FALSE);
} else {
$menu_link_manager->addDefinition($this->getPluginId(), $this->getPluginDefinition());
}
}
示例14: postSave
public function postSave(EntityStorageInterface $storage, $update = TRUE)
{
parent::postSave($storage, $update);
\Drupal::service('router.builder')->setRebuildNeeded();
}
示例15: postSave
/**
* {@inheritdoc}
*/
public function postSave(EntityStorageInterface $storage, $update = TRUE)
{
parent::postSave($storage, $update);
$icon_file = $this->getIconFile();
if (isset($this->original) && ($old_icon_file = $this->original->getIconFile())) {
/** @var \Drupal\file\FileInterface $old_icon_file */
if (!$icon_file || $icon_file->uuid() != $old_icon_file->uuid()) {
$this->fileUsage()->delete($old_icon_file, 'embed', $this->getEntityTypeId(), $this->id());
}
}
if ($icon_file) {
$usage = $this->fileUsage()->listUsage($icon_file);
if (empty($usage['embed'][$this->getEntityTypeId()][$this->id()])) {
$this->fileUsage()->add($icon_file, 'embed', $this->getEntityTypeId(), $this->id());
}
}
}