summaryrefslogtreecommitdiffstatshomepage
path: root/core/lib/Drupal/Core/Plugin/PreWarmablePluginManagerTrait.php
blob: 100f3b9e6b87b43b58e482dcab2a512c4c07f5c8 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
<?php

namespace Drupal\Core\Plugin;

/**
 * Provides a trait for Drupal\Core\PreWarm\PreWarmableInterface.
 *
 * For the vast majority of plugin managers, the ::getDefinitions() method does
 * exactly the right logic for cache prewarming, so this provides a default
 * implementation that uses that.
 *
 * @phpstan-require-implements \Drupal\Component\Plugin\Discovery\DiscoveryInterface
 * @phpstan-require-implements \Drupal\Core\PreWarm\PreWarmableInterface
 */
trait PreWarmablePluginManagerTrait {

  /**
   * Implements \Drupal\Core\PreWarm\PreWarmableInterface.
   */
  public function preWarm(): void {
    $this->getDefinitions();
  }

}