You are here

public function ToolbarController::flushPhp in Helper 8

Flush the PHP caches.

Return value

\Symfony\Component\HttpFoundation\RedirectResponse Reloads the page.

1 string reference to 'ToolbarController::flushPhp'
helper.routing.yml in ./helper.routing.yml
helper.routing.yml

File

src/Controller/ToolbarController.php, line 61

Class

ToolbarController
Toolbar controller.

Namespace

Drupal\helper\Controller

Code

public function flushPhp() {
  if (function_exists('opcache_reset')) {
    opcache_reset();
    $this
      ->messenger()
      ->addMessage($this
      ->t('PHP opcache cleared using opcache_reset().'));
  }
  if (function_exists('apc_cache_clear')) {
    apc_cache_clear();
    apc_clear_cache('user');
    apc_clear_cache('opcode');
    $this
      ->messenger()
      ->addMessage($this
      ->t('PHP APC cache cleared using apc_cache_clear().'));
  }
  clearstatcache();
  $this
    ->messenger()
    ->addMessage($this
    ->t('File status cache cleared using clearstatcache().'));
  return new RedirectResponse($this
    ->reloadPage());
}