/** * {@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()); } }
/** * {@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()); } }
/** * {@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 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(); } }
/** * {@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(); } }
/** * {@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()); } }
/** * {@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); } }
/** * {@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 { } } }
/** * {@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()); } }
/** * {@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(); } }
/** * {@inheritdoc} */ public function postSave(EntityStorageInterface $storage, $update = TRUE) { parent::postSave($storage, $update); // Clear render cache. entity_render_cache_clear(); }
/** * {@inheritdoc} */ public function postSave(EntityStorageInterface $storage, $update = TRUE) { parent::postSave($storage, $update); $this->routeBuilderIndicator()->setRebuildNeeded(); }
/** * {@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()); } }
public function postSave(EntityStorageInterface $storage, $update = TRUE) { parent::postSave($storage, $update); \Drupal::service('router.builder')->setRebuildNeeded(); }
/** * {@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()); } } }
/** * {@inheritdoc} */ public function postSave(EntityStorageInterface $storage, $update = TRUE) { parent::postSave($storage, $update); // @todo Remove if views implements a view_builder controller. views_invalidate_cache(); }
/** * {@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 { // Flush image style when updating without changing the name. $this->flush(); } } }
/** * {@inheritdoc} */ public function postSave(EntityStorageInterface $storage, $update = TRUE) { parent::postSave($storage, $update); $this->resetCaches(); try { // Fake an original for inserts to make code cleaner. $original = $update ? $this->original : static::create(array('status' => FALSE)); if ($this->status() && $original->status()) { // React on possible changes that would require re-indexing, etc. $this->reactToServerSwitch($original); $this->reactToDatasourceSwitch($original); $this->reactToTrackerSwitch($original); } elseif (!$this->status() && $original->status()) { if ($this->hasValidTracker()) { Utility::getIndexTaskManager()->stopTracking($this); } if ($original->isServerEnabled()) { $original->getServer()->removeIndex($this); } } elseif ($this->status() && !$original->status()) { $this->getServer()->addIndex($this); if ($this->hasValidTracker()) { Utility::getIndexTaskManager()->startTracking($this); } } if (\Drupal::moduleHandler()->moduleExists('views')) { Views::viewsData()->clear(); } $this->resetCaches(); } catch (SearchApiException $e) { watchdog_exception('search_api', $e); } }
/** * {@inheritdoc} */ public function postSave(EntityStorageInterface $storage, $update = TRUE) { parent::postSave($storage, $update); static::routeBuilder()->setRebuildNeeded(); }
/** * {@inheritdoc} */ public function postSave(EntityStorageInterface $storage, $update = TRUE) { parent::postSave($storage, $update); // @todo Remove if views implements a view_builder controller. views_invalidate_cache(); $this->invalidateCaches(); // Rebuild the router if this is a new view, or it's status changed. if (!isset($this->original) || $this->status() != $this->original->status()) { \Drupal::service('router.builder')->setRebuildNeeded(); } }
/** * {@inheritdoc} */ public function postSave(EntityStorageInterface $storage, $update = TRUE) { parent::postSave($storage, $update); // Clear the static caches of filter_formats() and others. filter_formats_reset(); if (!$update && !$this->isSyncing()) { // Default configuration of modules and installation profiles is allowed // to specify a list of user roles to grant access to for the new format; // apply the defined user role permissions when a new format is inserted // and has a non-empty $roles property. // Note: user_role_change_permissions() triggers a call chain back into // \Drupal\filter\FilterPermissions::permissions() and lastly // filter_formats(), so its cache must be reset upfront. if (($roles = $this->get('roles')) && ($permission = $this->getPermissionName())) { foreach (user_roles() as $rid => $name) { $enabled = in_array($rid, $roles, TRUE); user_role_change_permissions($rid, array($permission => $enabled)); } } } }
/** * {@inheritdoc} */ public function postSave(EntityStorageInterface $storage, $update = TRUE) { parent::postSave($storage, $update); // Create mode for the entity type. $mode_id = $this->entity_type . '.rng_event'; if (!EntityFormMode::load($mode_id)) { EntityFormMode::create(['id' => $mode_id, 'targetEntityType' => $this->entity_type, 'label' => 'Event Settings', 'status' => TRUE])->save(); } if (!$update) { module_load_include('inc', 'rng', 'rng.field.defaults'); foreach ($this->fields as $field) { rng_add_event_field_storage($field, $this->entity_type); rng_add_event_field_config($field, $this->getEventEntityTypeId(), $this->getEventBundle()); } } $display = entity_get_form_display($this->entity_type, $this->bundle, 'rng_event'); if ($display->isNew()) { // EntityDisplayBase::init() adds default fields. Remove them. foreach (array_keys($display->getComponents()) as $name) { if (!in_array($name, $this->fields)) { $display->removeComponent($name); } } // Weight is the key. $field_weights = [EventManagerInterface::FIELD_STATUS, EventManagerInterface::FIELD_ALLOW_DUPLICATE_REGISTRANTS, EventManagerInterface::FIELD_CAPACITY, EventManagerInterface::FIELD_EMAIL_REPLY_TO, EventManagerInterface::FIELD_REGISTRATION_TYPE, EventManagerInterface::FIELD_REGISTRATION_GROUPS]; module_load_include('inc', 'rng', 'rng.field.defaults'); foreach ($this->fields as $name) { rng_add_event_form_display_defaults($display, $name); if (in_array($name, $field_weights)) { $component = $display->getComponent($name); $component['weight'] = array_search($name, $field_weights); $display->setComponent($name, $component); } } $display->save(); } // Rebuild routes and local tasks. \Drupal::service('router.builder')->setRebuildNeeded(); // Rebuild local actions https://github.com/dpi/rng/issues/18 \Drupal::service('plugin.manager.menu.local_action')->clearCachedDefinitions(); }
/** * {@inheritdoc} */ public function postSave(EntityStorageInterface $storage_controller, $update = TRUE) { parent::postSave($storage_controller, $update); // Set bypass permissions. $roles = $this->getBypassRoles(); $permission = $this->getPermissionName(); if ($roles && $permission) { foreach (user_roles() as $rid => $name) { $enabled = in_array($rid, $roles, TRUE); user_role_change_permissions($rid, array($permission => $enabled)); } } }
/** * {@inheritdoc} */ public function postSave(EntityStorageInterface $storage, $update = TRUE) { parent::postSave($storage, $update); // @todo Remove if views implements a view_builder controller. views_invalidate_cache(); // Rebuild the router case the view got enabled. if (!isset($this->original) || $this->status() != $this->original->status()) { \Drupal::service('router.builder_indicator')->setRebuildNeeded(); } }