FileLoaderImportCircularReferenceException:循环引用 在" /app/config/routing_dev.yml"中检测到; (" /app/config/routing_dev.yml">
" /app/config/routing.yml" > "" > " @ GabrielAdminPanelBundle /控制器/" > " /app/config/routing_dev.yml")
我试图实现这个目标: http://symfony.com/doc/current/cookbook/routing/custom_route_loader.html#more-advanced-loaders
所以我创建了这个文件
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/routing.yml';
$type = 'yaml';
$importedRoutes = $this->import($resource, $type);
$collection->addCollection($importedRoutes);
return $collection;
}
public function supports($resource, $type = null)
{
return $type === 'advanced_extra';
}
}
/src/Gabriel/AdminPanelBundle/Resources/config/services.yml
services:
gabriel.routing_loader:
class: Gabriel\AdminPanelBundle\Routing\AdvancedLoader
tags:
- { name: routing.loader }
/app/config/routing.yml
gabriel_messaging:
resource: "@GabrielMessagingBundle/Controller/"
type: annotation
prefix: /
fos_js_routing:
resource: "@FOSJsRoutingBundle/Resources/config/routing/routing.xml"
# app/config/routing.yml
Gabriel_Extra:
resource: .
type: advanced_extra
应用程序/配置/ routing_dev.yml
_wdt:
resource: "@WebProfilerBundle/Resources/config/routing/wdt.xml"
prefix: /_wdt
_profiler:
resource: "@WebProfilerBundle/Resources/config/routing/profiler.xml"
prefix: /_profiler
_configurator:
resource: "@SensioDistributionBundle/Resources/config/routing/webconfigurator.xml"
prefix: /_configurator
_main:
resource: routing.yml
/src/Gabriel/AdminPanelBundle/Resources/config/routing.yml
gabriel_admin_panel:
resource: "@GabrielAdminPanelBundle/Controller/"
type: advanced_extra
prefix: /superuser
答案 0 :(得分:1)
仔细查看@GabrielAdminPanelBundle/Resources/config/routing.yml
:
gabriel_admin_panel:
resource: "@GabrielAdminPanelBundle/Controller/"
type: advanced_extra
prefix: /superuser
type
指定应该使用哪个加载器,在这种情况下,您说advanced_extra
,这是您的加载器。您的加载程序再次包含此文件,文件将再次执行加载程序,这将永远继续(换句话说:循环引用)。
另请注意,您已在app/config/routing.yml
中添加了路线:
gabriel_messaging:
resource: "@GabrielMessagingBundle/Controller/"
type: annotation
prefix: /
这次,您使用正确的类型:annotation
。您应该删除此条目并编辑@GabrielAdminPanelBundle/Resources/config/routing.yml
文件以使用正确的类型。