DB の値に従って、さまざまなバンドルから yml ルーティング ファイルを動的にロードしようとしています。クックブックに従ってカスタム ルート ローダーを作成しましたが、ファイルのインポート時にエラーが発生しました。私はSymfony 2.3に取り組んでいます。routing.ymlファイルにコレクションを手動で追加すると、ルーティングが正しく機能します。
リソースをロードするサービスを作成しました:
class ExtraLoader implements LoaderInterface
{
private $loaded = false;
public function load($resource, $type = null)
{
if (true === $this->loaded) {
throw new \RuntimeException('Do not add the "extra" loader twice');
}
$loader = new AdvancedLoader($this->getResolver());
$routes = new RouteCollection();
$route = $loader->import('@ERPExsecBBundle/Resources/config/routing.yml');
$route->addPrefix('/Production/');
$routes->addCollection($route);
$this->loaded = true;
return $routes;
}
[...]
}
クックブックで説明されている高度なローダー:
class AdvancedLoader extends Loader
{
public function __construct($resolver) {
$this->resolver = $resolver;
}
public function load($resource, $type = null)
{
$collection = new RouteCollection();
$type = 'yaml';
$importedRoutes = $this->import($resource, $type);
$collection->addCollection($importedRoutes);
return $importedRoutes;
}
public function supports($resource, $type = null)
{
return $type === 'advanced_extra';
}
}
しかし、私はエラーが発生しています:
致命的なエラー:「リソース "@ERPExsecBBundle/Resources/config/routing.yml" を読み込めません」というメッセージの例外「Symfony\Component\Config\Exception\FileLoaderLoadException」がキャッチされません。「ERPExsecBBundle/Resources/config/routing.yml」バンドルが正しく登録され、アプリケーション カーネル クラスにロードされていることを確認してください。C:\Program Files\wamp\www\alimerp\vendor\symfony\symfony\src\Symfony\Component\Config\Loader\Loader.php の 77 行目
なぜこのエラーが発生するのですか?