diff --git a/src/Entity/PageVariant.php b/src/Entity/PageVariant.php index 2b94fee..7ebc839 100644 --- a/src/Entity/PageVariant.php +++ b/src/Entity/PageVariant.php @@ -331,4 +331,30 @@ public function canSelect(AccountInterface $account = NULL) { return FALSE; } + /** + * {@inheritdoc} + */ + public function postSave(EntityStorageInterface $storage, $update = TRUE) { + parent::postSave($storage, $update); + static::routeBuilder()->setRebuildNeeded(); + } + + /** + * {@inheritdoc} + */ + public static function postDelete(EntityStorageInterface $storage, array $entities) { + parent::postDelete($storage, $entities); + static::routeBuilder()->setRebuildNeeded(); + } + + /** + * Wraps the route builder. + * + * @return \Drupal\Core\Routing\RouteBuilderInterface + * An object for state storage. + */ + protected static function routeBuilder() { + return \Drupal::service('router.builder'); + } + }