4

私はこれを達成しようとしています http://symfony.com/doc/current/cookbook/routing/custom_route_loader.html#more-advanced-loaders

バンドルの登録時にバンドル ルーティングを自動的にアクティブ化する必要があります

だから私はこのファイルをパスに作成しました

src/Gabriel\AdminPanelBundle\Routing\AdvancedLoader.php

内容とともに

<?php
//namespace Acme\DemoBundle\Routing;
namespace Gabriel\AdminPanelBundle\Routing;

use Symfony\Component\Config\Loader\Loader;
use Symfony\Component\Routing\RouteCollection;

class AdvancedLoader extends Loader
{
    public function load($resource, $type = null)
    {
        $collection = new RouteCollection();

        $resource = '@GabrielAdminPanelBundle/Resources/config/import_routing.yml';
        $type = 'yaml';

        $importedRoutes = $this->import($resource, $type);

        $collection->addCollection($importedRoutes);

        return $collection;
    }

    public function supports($resource, $type = null)
    {
        return $type === 'advanced_extra';
    }
}

この構成をコピーしました

gabriel_admin_panel:
    resource: "@GabrielAdminPanelBundle/Controller/"
    type:     annotation
    prefix:   /superuser

から

/app/config/routing.yml

それを自分の構成ファイルに貼り付けました

/src/Gabriel/AdminPanelBundle/Resources/config/import_routing.yml

問題:

Symfony2 は私の AdvancedLoader.php ファイルを完全に無視します。構文エラーを入れることができ、サイトはエラーをスローしません。また、router:debug はバンドル内で定義されているルートを表示しません。構成を元の router.yml ファイルに戻します。

PS: キャッシュをクリアしても何も変わらない

編集: サービスとリソースを追加すると、このエラーが表示されます

FileLoaderImportCircularReferenceException: "/app/config/routing_dev.yml" ("/app/config/routing_dev.yml" > "/app/config/routing.yml" > "." > "@GabrielAdminPanelBundle/Controller/" で循環参照が検出されました> "/app/config/routing_dev.yml")。

4

1 に答える 1