function CacheRebuildCommand::__invoke
Same name and namespace in other branches
- 11.x core/lib/Drupal/Core/Command/CacheRebuildCommand.php \Drupal\Core\Command\CacheRebuildCommand::__invoke()
Rebuild all caches.
File
-
core/
lib/ Drupal/ Core/ Command/ CacheRebuildCommand.php, line 39
Class
- CacheRebuildCommand
- Rebuild all caches.
Namespace
Drupal\Core\CommandCode
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;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.