class Hooks in Lightning Core 8.3
Same name and namespace in other branches
- 8.5 src/Commands/Hooks.php \Drupal\lightning_core\Commands\Hooks
- 8.2 src/Commands/Hooks.php \Drupal\lightning_core\Commands\Hooks
- 8.4 src/Commands/Hooks.php \Drupal\lightning_core\Commands\Hooks
Implements Drush command hooks.
Hierarchy
- class \Drupal\lightning_core\Commands\Hooks extends \Drush\Commands\DrushCommands
Expanded class hierarchy of Hooks
1 string reference to 'Hooks'
1 service uses Hooks
File
- src/
Commands/ Hooks.php, line 11
Namespace
Drupal\lightning_core\CommandsView source
class Hooks extends DrushCommands {
/**
* The plugin cache clearer service.
*
* @var \Drupal\Core\Plugin\CachedDiscoveryClearerInterface
*/
private $pluginCacheClearer;
/**
* Hooks constructor.
*
* @param \Drupal\Core\Plugin\CachedDiscoveryClearerInterface $plugin_cache_clearer
* The plugin cache clearer service.
*/
public function __construct(CachedDiscoveryClearerInterface $plugin_cache_clearer) {
$this->pluginCacheClearer = $plugin_cache_clearer;
}
/**
* Clears all plugin caches before database updates begin.
*
* A common cause of errors during database updates is update hooks
* inadvertently using stale data from the myriad caches in Drupal core and
* contributed modules. To migitate this, we do a bit of cache pruning before
* database updates begin.
*
* drupal_flush_all_caches() is extremely aggressive because it rebuilds the
* router and other things, but it's a bit too much of a sledgehammer for our
* purposes. A good compromise is to clear all plugin discovery caches (which
* will include entity type definitions).
*
* @hook pre-command updatedb
*/
public function preUpdate() {
$this->pluginCacheClearer
->clearCachedDefinitions();
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
Hooks:: |
private | property | The plugin cache clearer service. | |
Hooks:: |
public | function | Clears all plugin caches before database updates begin. | |
Hooks:: |
public | function | Hooks constructor. |