dbConnection = $db_connection; } /** * {@inheritdoc} */ public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) { return new static( $configuration, $plugin_id, $plugin_definition, $container->get('menu_link.static.overrides'), $container->get('database') ); } /** * {@inheritdoc} */ public function getTitle() { $count = $this->dbConnection->query('SELECT COUNT(*) FROM {messages}')->fetchField(); return $this->t('Messages (@count)', ['@count' => $count]); } /** * {@inheritdoc} */ public function getRouteName() { return '{{ machine_name }}.messages'; } /** * {@inheritdoc} */ public function getCacheTags() { // @DCG Invalidate this tags when messages are created or removed. return ['{{ machine_name }}.messages_count']; } }