1 回答

TA貢獻1820條經驗 獲得超3個贊
更新:
因此,我做了更多的實驗,因為我收集的目的是在列出路線時使用“標簽”數據。我認為使用默認部分仍然更容易,但您可以使用路由集合訪問選項信息:
class PlayCommand extends Command
{
protected static $defaultName = 'app:play';
private RouterInterface $router;
public function __construct(RouterInterface $router)
{
parent::__construct();
$this->router = $router;
}
protected function execute(InputInterface $input, OutputInterface $output): int
{
$routes = $this->router->getRouteCollection();
$route = $routes->get('index');
$label = $route->getOption('label');
不確定是否有一種方法可以直接從樹枝內部獲取路線,但為此編寫一個樹枝擴展很容易。
原答案:
默認部分用于提供附加信息。
我很難找到選項部分的文檔。這篇博客文章討論了一些新選項,例如 utf-8 支持。我認為選項部分是由路由器使用的。不積極。
/**
* @Route("/", name="index", options={"label"="COMMMON_CLIENTMANAGEMENT"})
*/
- 1 回答
- 0 關注
- 168 瀏覽
添加回答
舉報