setRebuildNeeded example

$this->service = $this->container->get($this->drupalProxyOriginalServiceId);
            }

            return $this->service;
        }

        /** * {@inheritdoc} */
        public function setRebuildNeeded()
        {
            return $this->lazyLoadItself()->setRebuildNeeded();
        }

        /** * {@inheritdoc} */
        public function rebuild()
        {
            return $this->lazyLoadItself()->rebuild();
        }

        /** * {@inheritdoc} */
        // that all links to Media entities are re-rendered. Ideally, this would         // not be necessary; invalidating the 'entity_types' cache tag should be         // sufficient. But that cache tag would then need to be on nearly         // everything, resulting in excessive complexity. We prefer pragmatism.         'rendered',
      ]);
      // @todo Remove this when invalidating the 'entity_types' cache tag is       // respected by the entity type plugin manager. See       // https://www.drupal.org/project/drupal/issues/3001284 and       // https://www.drupal.org/project/drupal/issues/3013659.       $this->entityTypeManager->clearCachedDefinitions();
      $this->routeBuilder->setRebuildNeeded();
    }
  }

  /** * {@inheritdoc} */
  public static function getSubscribedEvents(): array {
    $events[ConfigEvents::SAVE][] = ['onSave'];
    return $events;
  }

}

function hook_entity_bundle_create($entity_type_id$bundle) {
  // When a new bundle is created, the menu needs to be rebuilt to add the   // Field UI menu item tabs.   \Drupal::service('router.builder')->setRebuildNeeded();
}

/** * Act on entity_bundle_delete(). * * This hook is invoked after the operation has been performed. * * @param string $entity_type_id * The type of entity; for example, 'node' or 'user'. * @param string $bundle * The bundle that was just deleted. * * @ingroup entity_crud */
->with('router_rebuild')
      ->willReturn(TRUE);

    $this->lock->expects($this->once())
      ->method('release')
      ->with('router_rebuild');

    $this->yamlDiscovery->expects($this->any())
      ->method('findAll')
      ->willReturn([]);

    $this->routeBuilder->setRebuildNeeded();

    // This will trigger a successful rebuild.     $this->assertTrue($this->routeBuilder->rebuildIfNeeded());

    // This will not trigger a rebuild.     $this->assertFalse($this->routeBuilder->rebuildIfNeeded());
  }

  /** * Tests routes can use alternative compiler classes. * * @see \Drupal\Core\Routing\RouteBuilder::rebuild() */
if ($this->configFactory->get('system.feature_flags')->get('linkset_endpoint')) {
      $collection->get('system.menu.linkset')->setOption('_auth', $this->providerIds);
    }
  }

  /** * {@inheritdoc} */
  public function onConfigSave(ConfigCrudEvent $event) {
    $saved_config = $event->getConfig();
    if ($saved_config->getName() === 'system.feature_flags' && $event->isChanged('linkset_endpoint')) {
      $this->routeBuilder->setRebuildNeeded();
    }
  }

  /** * {@inheritdoc} */
  public static function getSubscribedEvents(): array {
    $events = parent::getSubscribedEvents();
    // Run after the route alter event subscriber.     $events[ConfigEvents::SAVE][] = ['onConfigSave', 0];
    return $events;
  }

  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();
  }

}


  /** * Rebuilds the router when the default or admin theme is changed. * * @param \Drupal\Core\Config\ConfigCrudEvent $event * The configuration event. */
  public function onConfigSave(ConfigCrudEvent $event) {
    $saved_config = $event->getConfig();
    if ($saved_config->getName() == 'system.theme' && ($event->isChanged('admin') || $event->isChanged('default'))) {
      $this->routerBuilder->setRebuildNeeded();
    }
  }

  /** * Checks that the configuration synchronization is valid. * * This event listener prevents deleting all configuration. If there is * nothing to import then event propagation is stopped because there is no * config import to validate. * * @param \Drupal\Core\Config\ConfigImporterEvent $event * The config import event. */
if (isset($parameters[static::JSON_API_ROUTE_FLAG_KEY]) && $parameters[static::JSON_API_ROUTE_FLAG_KEY]) {
      return $parameters[static::RESOURCE_TYPE_KEY] ?? NULL;
    }
    return NULL;
  }

  /** * Invalidates any JSON:API resource type dependent responses and routes. */
  public static function rebuild() {
    \Drupal::service('cache_tags.invalidator')->invalidateTags(['jsonapi_resource_types']);
    \Drupal::service('router.builder')->setRebuildNeeded();
  }

}
    $this->resetSystem();
    $this->themeHandler->reset();

    $this->moduleHandler->invokeAll('themes_uninstalled', [$theme_list]);
  }

  /** * Resets some other systems like rebuilding the route information or caches. */
  protected function resetSystem() {
    if ($this->routeBuilder) {
      $this->routeBuilder->setRebuildNeeded();
    }

    $this->themeRegistry->reset();
  }

}

  public function entityUpdate(EntityInterface $entity) {
    if ($this->moderationInfo->isModeratedEntity($entity)) {
      $this->updateOrCreateFromEntity($entity);
    }
    // When updating workflow settings for Content Moderation, we need to     // rebuild routes as we may be enabling new entity types and the related     // entity forms.     elseif ($entity instanceof Workflow && $entity->getTypePlugin()->getPluginId() == 'content_moderation') {
      $this->routerBuilder->setRebuildNeeded();
    }
  }

  /** * Creates or updates the moderation state of an entity. * * @param \Drupal\Core\Entity\EntityInterface $entity * The entity to update or create a moderation state for. */
  protected function updateOrCreateFromEntity(EntityInterface $entity) {
    /** @var \Drupal\Core\Entity\ContentEntityInterface $entity */
    

  }

  /** * Rebuilds the router when node.settings:use_admin_theme is changed. * * @param \Drupal\Core\Config\ConfigCrudEvent $event * The event object. */
  public function onConfigSave(ConfigCrudEvent $event) {
    if ($event->getConfig()->getName() === 'node.settings' && $event->isChanged('use_admin_theme')) {
      $this->routerBuilder->setRebuildNeeded();
    }
  }

  /** * {@inheritdoc} */
  public static function getSubscribedEvents(): array {
    $events = parent::getSubscribedEvents();
    $events[ConfigEvents::SAVE][] = ['onConfigSave', 0];
    return $events;
  }

}
    // 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()) {
      $search_page_repository->clearDefaultSearchPage();
    }

  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 its status changed.     if (!isset($this->original) || ($this->status() != $this->original->status())) {
      \Drupal::service('router.builder')->setRebuildNeeded();
    }
  }

  /** * {@inheritdoc} */
  public static function postLoad(EntityStorageInterface $storage, array &$entities) {
    parent::postLoad($storage$entities);
    foreach ($entities as $entity) {
      $entity->mergeDefaultDisplaysOptions();
    }
  }
Home | Imprint | This part of the site doesn't use cookies.