class CacheRebuildCommand
Same name and namespace in other branches
- main core/lib/Drupal/Core/Command/CacheRebuildCommand.php \Drupal\Core\Command\CacheRebuildCommand
Rebuild all caches.
@internal
Attributes
#[AsCommand(name: 'cache:rebuild', description: 'Rebuild all caches.', aliases: [
'cr',
'rebuild',
])]
Hierarchy
- class \Drupal\Core\Command\CacheRebuildCommand
Expanded class hierarchy of CacheRebuildCommand
1 file declares its use of CacheRebuildCommand
- CacheRebuildCommandTest.php in core/
tests/ Drupal/ FunctionalTests/ Core/ Console/ CacheRebuildCommandTest.php
File
-
core/
lib/ Drupal/ Core/ Command/ CacheRebuildCommand.php, line 22
Namespace
Drupal\Core\CommandView source
class CacheRebuildCommand {
public function __construct(protected ClassLoader $classLoader) {
}
/**
* Rebuild all caches.
*/
public function __invoke(InputInterface $input, OutputInterface $output) : int {
$io = new SymfonyStyle($input, $output);
// Prior to booting the kernel, change the current working directory to the
// Drupal root temporarily, which may either be the current working
// directory or within the document or web root. This is done because the
// YAML file loader uses a relative directory to find core.services.yml.
// @todo https://www.drupal.org/node/2899837
$cwd = getcwd();
chdir(DRUPAL_ROOT);
$request = Request::createFromGlobals();
// Manually resemble early bootstrap of DrupalKernel::boot().
DrupalKernel::bootEnvironment();
Settings::initialize(DRUPAL_ROOT, DrupalKernel::findSitePath($request), $this->classLoader);
require_once DRUPAL_ROOT . '/core/includes/utility.inc';
drupal_rebuild($this->classLoader, $request);
$io->success('All caches have been rebuilt.');
// Restores the current working directory of the command to the app root.
chdir($cwd);
return Command::SUCCESS;
}
}
Members
| Title Sort descending | Modifiers | Object type | Summary |
|---|---|---|---|
| CacheRebuildCommand::__construct | public | function | |
| CacheRebuildCommand::__invoke | public | function | Rebuild all caches. |
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.