class ToolbarController in Admin Toolbar 8
Same name and namespace in other branches
- 8.2 admin_toolbar_tools/src/Controller/ToolbarController.php \Drupal\admin_toolbar_tools\Controller\ToolbarController
- 3.x admin_toolbar_tools/src/Controller/ToolbarController.php \Drupal\admin_toolbar_tools\Controller\ToolbarController
Class ToolbarController.
@package Drupal\admin_toolbar_tools\Controller
Hierarchy
- class \Drupal\Core\Controller\ControllerBase implements ContainerInjectionInterface uses LoggerChannelTrait, MessengerTrait, LinkGeneratorTrait, RedirectDestinationTrait, UrlGeneratorTrait, StringTranslationTrait
- class \Drupal\admin_toolbar_tools\Controller\ToolbarController
Expanded class hierarchy of ToolbarController
File
- admin_toolbar_tools/
src/ Controller/ ToolbarController.php, line 24
Namespace
Drupal\admin_toolbar_tools\ControllerView source
class ToolbarController extends ControllerBase {
/**
* A cron instance.
*
* @var \Drupal\Core\CronInterface
*/
protected $cron;
/**
* A menu link manager instance.
*
* @var \Drupal\Core\Menu\MenuLinkManagerInterface
*/
protected $menuLinkManager;
/**
* A context link manager instance.
*
* @var \Drupal\Core\Menu\ContextualLinkManagerInterface
*/
protected $contextualLinkManager;
/**
* A local task manager instance.
*
* @var \Drupal\Core\Menu\LocalTaskManagerInterface
*/
protected $localTaskLinkManager;
/**
* A local action manager instance.
*
* @var \Drupal\Core\Menu\LocalActionManagerInterface
*/
protected $localActionLinkManager;
/**
* A cache backend interface instance.
*
* @var \Drupal\Core\Cache\CacheBackendInterface
*/
protected $cacheRender;
/**
* A date time instance.
*
* @var \Drupal\Component\Datetime\TimeInterface
*/
protected $time;
/**
* A request stack symfony instance.
*
* @var \Symfony\Component\HttpFoundation\RequestStack
*/
protected $requestStack;
/**
* A plugin cache clear instance.
*
* @var \Drupal\Core\Plugin\CachedDiscoveryClearerInterface
*/
protected $pluginCacheClearer;
/**
* The cache menu instance.
*
* @var \Drupal\Core\Cache\CacheBackendInterface
*/
protected $cacheMenu;
/**
* A TwigEnvironment instance.
*
* @var \Drupal\Core\Template\TwigEnvironment
*/
protected $twig;
/**
* Constructs a ToolbarController object.
*
* @param \Drupal\Core\CronInterface $cron
* A cron instance.
* @param \Drupal\Core\Menu\MenuLinkManagerInterface $menuLinkManager
* A menu link manager instance.
* @param \Drupal\Core\Menu\ContextualLinkManagerInterface $contextualLinkManager
* A context link manager instance.
* @param \Drupal\Core\Menu\LocalTaskManagerInterface $localTaskLinkManager
* A local task manager instance.
* @param \Drupal\Core\Menu\LocalActionManagerInterface $localActionLinkManager
* A local action manager instance.
* @param \Drupal\Core\Cache\CacheBackendInterface $cacheRender
* A cache backend interface instance.
* @param \Drupal\Component\Datetime\TimeInterface $time
* A date time instance.
* @param \Symfony\Component\HttpFoundation\RequestStack $request_stack
* A request stack symfony instance.
* @param \Drupal\Core\Plugin\CachedDiscoveryClearerInterface $plugin_cache_clearer
* A plugin cache clear instance.
* @param \Drupal\Core\Cache\CacheBackendInterface $cache_menu
* A cache menu instance.
* @param \Drupal\Core\Template\TwigEnvironment $twig
* A TwigEnvironment instance.
*/
public function __construct(CronInterface $cron, MenuLinkManagerInterface $menuLinkManager, ContextualLinkManagerInterface $contextualLinkManager, LocalTaskManagerInterface $localTaskLinkManager, LocalActionManagerInterface $localActionLinkManager, CacheBackendInterface $cacheRender, TimeInterface $time, RequestStack $request_stack, CachedDiscoveryClearerInterface $plugin_cache_clearer, CacheBackendInterface $cache_menu, TwigEnvironment $twig) {
$this->cron = $cron;
$this->menuLinkManager = $menuLinkManager;
$this->contextualLinkManager = $contextualLinkManager;
$this->localTaskLinkManager = $localTaskLinkManager;
$this->localActionLinkManager = $localActionLinkManager;
$this->cacheRender = $cacheRender;
$this->time = $time;
$this->requestStack = $request_stack;
$this->pluginCacheClearer = $plugin_cache_clearer;
$this->cacheMenu = $cache_menu;
$this->twig = $twig;
}
/**
* {@inheritdoc}
*/
public static function create(ContainerInterface $container) {
return new static($container
->get('cron'), $container
->get('plugin.manager.menu.link'), $container
->get('plugin.manager.menu.contextual_link'), $container
->get('plugin.manager.menu.local_task'), $container
->get('plugin.manager.menu.local_action'), $container
->get('cache.render'), $container
->get('datetime.time'), $container
->get('request_stack'), $container
->get('plugin.cache_clearer'), $container
->get('cache.menu'), $container
->get('twig'));
}
/**
* Reload the previous page.
*/
public function reloadPage() {
$request = $this->requestStack
->getCurrentRequest();
if ($request->server
->get('HTTP_REFERER')) {
return $request->server
->get('HTTP_REFERER');
}
else {
return '/';
}
}
/**
* Flushes all caches.
*/
public function flushAll() {
$this
->messenger()
->addMessage($this
->t('All caches cleared.'));
drupal_flush_all_caches();
return new RedirectResponse($this
->reloadPage());
}
/**
* Flushes css and javascript caches.
*/
public function flushJsCss() {
$this
->state()
->set('system.css_js_query_string', base_convert($this->time
->getCurrentTime(), 10, 36));
$this
->messenger()
->addMessage($this
->t('CSS and JavaScript cache cleared.'));
return new RedirectResponse($this
->reloadPage());
}
/**
* Flushes plugins caches.
*/
public function flushPlugins() {
$this->pluginCacheClearer
->clearCachedDefinitions();
$this
->messenger()
->addMessage($this
->t('Plugins cache cleared.'));
return new RedirectResponse($this
->reloadPage());
}
/**
* Resets all static caches.
*/
public function flushStatic() {
drupal_static_reset();
$this
->messenger()
->addMessage($this
->t('Static cache cleared.'));
return new RedirectResponse($this
->reloadPage());
}
/**
* Clears all cached menu data.
*/
public function flushMenu() {
$this->cacheMenu
->invalidateAll();
$this->menuLinkManager
->rebuild();
$this->contextualLinkManager
->clearCachedDefinitions();
$this->localTaskLinkManager
->clearCachedDefinitions();
$this->localActionLinkManager
->clearCachedDefinitions();
$this
->messenger()
->addMessage($this
->t('Routing and links cache cleared.'));
return new RedirectResponse($this
->reloadPage());
}
/**
* Clears all cached views data.
*/
public function flushViews() {
views_invalidate_cache();
$this
->messenger()
->addMessage($this
->t('Views cache cleared.'));
return new RedirectResponse($this
->reloadPage());
}
/**
* Clears the twig cache.
*/
public function flushTwig() {
$this->twig
->invalidate();
$this
->messenger()
->addMessage($this
->t('Twig cache cleared.'));
return new RedirectResponse($this
->reloadPage());
}
/**
* Run the cron.
*/
public function runCron() {
$this->cron
->run();
$this
->messenger()
->addMessage($this
->t('Cron ran successfully.'));
return new RedirectResponse($this
->reloadPage());
}
/**
* Clear the rendered cache.
*/
public function cacheRender() {
$this->cacheRender
->invalidateAll();
$this
->messenger()
->addMessage($this
->t('Render cache cleared.'));
return new RedirectResponse($this
->reloadPage());
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
ControllerBase:: |
protected | property | The configuration factory. | |
ControllerBase:: |
protected | property | The current user service. | 1 |
ControllerBase:: |
protected | property | The entity form builder. | |
ControllerBase:: |
protected | property | The entity manager. | |
ControllerBase:: |
protected | property | The entity type manager. | |
ControllerBase:: |
protected | property | The form builder. | 2 |
ControllerBase:: |
protected | property | The key-value storage. | 1 |
ControllerBase:: |
protected | property | The language manager. | 1 |
ControllerBase:: |
protected | property | The module handler. | 2 |
ControllerBase:: |
protected | property | The state service. | |
ControllerBase:: |
protected | function | Returns the requested cache bin. | |
ControllerBase:: |
protected | function | Retrieves a configuration object. | |
ControllerBase:: |
private | function | Returns the service container. | |
ControllerBase:: |
protected | function | Returns the current user. | 1 |
ControllerBase:: |
protected | function | Retrieves the entity form builder. | |
ControllerBase:: |
protected | function | Retrieves the entity manager service. | |
ControllerBase:: |
protected | function | Retrieves the entity type manager. | |
ControllerBase:: |
protected | function | Returns the form builder service. | 2 |
ControllerBase:: |
protected | function | Returns a key/value storage collection. | 1 |
ControllerBase:: |
protected | function | Returns the language manager service. | 1 |
ControllerBase:: |
protected | function | Returns the module handler. | 2 |
ControllerBase:: |
protected | function |
Returns a redirect response object for the specified route. Overrides UrlGeneratorTrait:: |
|
ControllerBase:: |
protected | function | Returns the state storage service. | |
LinkGeneratorTrait:: |
protected | property | The link generator. | 1 |
LinkGeneratorTrait:: |
protected | function | Returns the link generator. | |
LinkGeneratorTrait:: |
protected | function | Renders a link to a route given a route name and its parameters. | |
LinkGeneratorTrait:: |
public | function | Sets the link generator service. | |
LoggerChannelTrait:: |
protected | property | The logger channel factory service. | |
LoggerChannelTrait:: |
protected | function | Gets the logger for a specific channel. | |
LoggerChannelTrait:: |
public | function | Injects the logger channel factory. | |
MessengerTrait:: |
protected | property | The messenger. | 29 |
MessengerTrait:: |
public | function | Gets the messenger. | 29 |
MessengerTrait:: |
public | function | Sets the messenger. | |
RedirectDestinationTrait:: |
protected | property | The redirect destination service. | 1 |
RedirectDestinationTrait:: |
protected | function | Prepares a 'destination' URL query parameter for use with \Drupal\Core\Url. | |
RedirectDestinationTrait:: |
protected | function | Returns the redirect destination service. | |
RedirectDestinationTrait:: |
public | function | Sets the redirect destination service. | |
StringTranslationTrait:: |
protected | property | The string translation service. | 1 |
StringTranslationTrait:: |
protected | function | Formats a string containing a count of items. | |
StringTranslationTrait:: |
protected | function | Returns the number of plurals supported by a given language. | |
StringTranslationTrait:: |
protected | function | Gets the string translation service. | |
StringTranslationTrait:: |
public | function | Sets the string translation service to use. | 2 |
StringTranslationTrait:: |
protected | function | Translates a string to the current language or to a given language. | |
ToolbarController:: |
protected | property | The cache menu instance. | |
ToolbarController:: |
protected | property | A cache backend interface instance. | |
ToolbarController:: |
protected | property | A context link manager instance. | |
ToolbarController:: |
protected | property | A cron instance. | |
ToolbarController:: |
protected | property | A local action manager instance. | |
ToolbarController:: |
protected | property | A local task manager instance. | |
ToolbarController:: |
protected | property | A menu link manager instance. | |
ToolbarController:: |
protected | property | A plugin cache clear instance. | |
ToolbarController:: |
protected | property | A request stack symfony instance. | |
ToolbarController:: |
protected | property | A date time instance. | |
ToolbarController:: |
protected | property | A TwigEnvironment instance. | |
ToolbarController:: |
public | function | Clear the rendered cache. | |
ToolbarController:: |
public static | function |
Instantiates a new instance of this class. Overrides ControllerBase:: |
|
ToolbarController:: |
public | function | Flushes all caches. | |
ToolbarController:: |
public | function | Flushes css and javascript caches. | |
ToolbarController:: |
public | function | Clears all cached menu data. | |
ToolbarController:: |
public | function | Flushes plugins caches. | |
ToolbarController:: |
public | function | Resets all static caches. | |
ToolbarController:: |
public | function | Clears the twig cache. | |
ToolbarController:: |
public | function | Clears all cached views data. | |
ToolbarController:: |
public | function | Reload the previous page. | |
ToolbarController:: |
public | function | Run the cron. | |
ToolbarController:: |
public | function | Constructs a ToolbarController object. | |
UrlGeneratorTrait:: |
protected | property | The url generator. | |
UrlGeneratorTrait:: |
protected | function | Returns the URL generator service. | |
UrlGeneratorTrait:: |
public | function | Sets the URL generator service. | |
UrlGeneratorTrait:: |
protected | function | Generates a URL or path for a specific route based on the given parameters. |