-1

それがどのように機能するかを見たいです。特に、「_」で展開を実行している場合、または渡したパラメーターに基づいて同等のキーをルーティングで検索している場合。

ドキュメント、ネット、およびコードベースを検索しましたが、それがどこにあるかについての情報はあまりありません。symfonyのドキュメントは、リンクを構築するときにそれを使用します。

    {# src/Acme/TaskBundle/Resources/views/Default/new.html.twig #}
    <form action="{{ path('task_new') }}" method="post" {{ form_enctype(form) }}>
        {{ form_widget(form) }}

        <input type="submit" />
    </form>

ルーティングファイルのキーを使用しているようです。したがって、次のコード:

    {{ path('_welcome') }}

ルーティングで「_welcome」のキーを持つルーティングを探します。

yaml

    _welcome:
        pattern:   /
        defaults:  { _controller: AcmeDemoBundle:Main:homepage }

php

    use Symfony\Component\Routing\RouteCollection;
    use Symfony\Component\Routing\Route;

    $collection = new RouteCollection();
    $collection->add('_welcome', new Route('/', array(
        '_controller' => 'AcmeDemoBundle:Main:homepage',
    )));

    return $collection;    
4

1 に答える 1

3

これはで定義されています

https://github.com/symfony/symfony/blob/master/src/Symfony/Bridge/Twig/Extension/RoutingExtension.php

これを利用します

https://github.com/symfony/symfony/blob/master/src/Symfony/Component/Routing/Generator/UrlGenerator.php

とにかく、'_'で爆発していないことを確認できます

于 2012-08-06T21:04:43.603 に答える