Newbie from Symfony framework here. I'm trying to go trough How to Create a custom Route Loader Cookbook section and make routing autoloading working in my bundle but without a success. Here are all related to this topic files:
Loader:
namespace Notimeo\CoreBundle\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 = '@NotimeoCoreBundle/Resources/config/import_routing.yml';
$type = 'yaml';
$importedRoutes = $this->import($resource, $type);
$collection->addCollection($importedRoutes);
return $collection;
}
public function supports($resource, $type = null)
{
return 'advanced_extra' === $type;
}
}
DependencyInjection:
namespace Notimeo\CoreBundle\DependencyInjection;
use Symfony\Component\DependencyInjection\Extension\PrependExtensionInterface;
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Loader\YamlFileLoader;
use Symfony\Component\Config\FileLocator;
class CoreExtension extends Extension implements PrependExtensionInterface
{
public function load(array $configs, ContainerBuilder $container)
{
}
public function prepend(ContainerBuilder $container)
{
$loader = new YamlFileLoader(
$container,
new FileLocator(__DIR__.'/../Resources/config')
);
$loader->load('services.yml');
}
}
src/Notimeo/CoreBundle/Resources/config/routing.yml:
notimeo_core_routes:
resource: .
type: advanced_extra
src/Notimeo/CoreBundle/Resources/config/import_routing.yml:
# homepage
homepage:
path: /
defaults:
_controller: CoreBundle:Base:index
src/Notimeo/CoreBundle/Resources/config/services.yml:
services:
routing.loader.advanced_loader:
class: Notimeo\CoreBundle\Routing\AdvancedLoader
tags:
- { name: routing.loader }
Getting No route found for "GET /"
error...
(using Symfony 3)
UPDATE:
Well... it's working if I will move content of src/Notimeo/CoreBundle/Resources/config/routing.yml:
to
app/config/routing.yml.
But... why? Why I can't put all contents in my bundle?