Skip to content

Commit

Permalink
Add function node_types_rebuild()
Browse files Browse the repository at this point in the history
  • Loading branch information
darrenoh committed Mar 7, 2024
1 parent 464fe7f commit fbe835e
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/functions/node.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

declare(strict_types=1);

use Drupal\Core\Cache\Cache;
use Drupal\Core\Config\StorageCacheInterface;
use Drupal\Core\Entity\EntityInterface;
use Drupal\node\Entity\NodeType;
use Drupal\node\NodeTypeInterface;
Expand Down Expand Up @@ -72,3 +74,12 @@ function node_type_delete(string $type): void
$nodeType = NodeType::load($type);
$nodeType?->delete();
}

function node_types_rebuild(): void
{
$tags = \Drupal::config('node_type')->getCacheTags();
$tags[] = 'config:node_type_list';
Cache::invalidateTags($tags);
$storage = \Drupal::service('config.storage');
$storage->resetListCache();
}

0 comments on commit fbe835e

Please sign in to comment.