1

私はsymfony2がここで説明しているのと同じ問題を抱えています

これは、バンドルがあるが、バンドルのルートを に手動で追加したくない場合に便利ですapp/config/routing.yml。これは、バンドルを再利用可能にしたい場合に特に重要です。

TLDR; symfony2 ドキュメントのこの部分を使用してカスタム ルート ローダーを実装しようとしています http://symfony.com/doc/current/cookbook/routing/custom_route_loader.html#more-advanced-loaders

ただし、機能していないようです。ルートが見つかりません。

これは私がこれまでに試したことです: ローダー:

<?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/routing.yml';
        $type = 'yaml';

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

        $collection->addCollection($importedRoutes);

        return $collection;
    }

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

ここに私のrouting.ymlがあります

located in: src/Gabriel/AdminPanelBundle/Resources/config/routing.yml

routing.yml

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

ルートをメインの app/config/routing.yml ファイルに戻さない限り、バンドルのルートが見つかりません。これを修正するにはどうすればよいですか?

編集:

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

1

サービスも構成する必要があります

# src/Gabriel/AdminPanelBundle/Resources/config/services.yml
your_bundle.routing_loader:
    class: Gabriel\AdminPanelBundle\Routing\AdvancedLoader
    tags:
        - { name: routing.loader }

ルーティングファイル

# app/config/routing.yml
YourBundle_extra:
    resource: .
    type: advanced_extra
于 2015-01-21T18:32:56.087 に答える