TestLocalActionWithConfig.php in Drupal 10
File
core/modules/system/tests/modules/menu_test/src/Plugin/Menu/LocalAction/TestLocalActionWithConfig.php
View source
<?php
namespace Drupal\menu_test\Plugin\Menu\LocalAction;
use Drupal\Core\Config\Config;
use Drupal\Core\Menu\LocalActionDefault;
use Drupal\Core\Routing\RouteProviderInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\HttpFoundation\Request;
class TestLocalActionWithConfig extends LocalActionDefault {
protected $config;
public function getTitle(Request $request = NULL) {
return $this->config
->get('title');
}
public function __construct(array $configuration, $plugin_id, $plugin_definition, RouteProviderInterface $route_provider, Config $config) {
parent::__construct($configuration, $plugin_id, $plugin_definition, $route_provider);
$this->config = $config;
}
public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) {
return new static($configuration, $plugin_id, $plugin_definition, $container
->get('router.route_provider'), $container
->get('config.factory')
->get('menu_test.links.action'));
}
}