Skip to content

Using a service as a router resource #15742

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 18 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fabbot
  • Loading branch information
weaverryan committed Sep 30, 2015
commit 7ed22ce5fe04ab2fd3918e28b08819b9803e5a6e
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,8 @@
namespace Symfony\Component\Routing\Loader\DependencyInjection;

use Symfony\Component\Config\Loader\Loader;
use Symfony\Component\Config\Resource\FileResource;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\Routing\Loader\ObjectRouteLoader;
use Symfony\Component\Routing\Loader\RouteLoaderInterface;
use Symfony\Component\Routing\RouteCollection;

/**
* A route loader that executes a service to load the routes.
Expand Down
1 change: 1 addition & 0 deletions src/Symfony/Component/Routing/Loader/ObjectRouteLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ public function supports($resource, $type = null)
* the $id may be a service id.
*
* @param string $id
*
* @return RouteLoaderInterface
*/
abstract protected function getRouteLoaderService($id);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could remove the RouteLoaderInterface and instead have this method return a callable.

The difference would then be that we'd probably need to include the method name in the "resource" when using this:

admin_routes:
    resource: 'admin_route_loader::loadRoutes'
    type: service

That would solve the need for the RouteLoaderInterface on the "Micro" kernel.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
namespace Symfony\Component\Routing\Tests\Loader;

use Symfony\Component\Routing\Loader\ObjectRouteLoader;
use Symfony\Component\Routing\Loader\RouteLoaderInterface;
use Symfony\Component\Routing\Route;
use Symfony\Component\Routing\RouteCollection;

Expand All @@ -24,7 +23,7 @@ public function testLoadCallsServiceAndReturnsCollection()
$serviceRouteLoader = new ObjectRouteLoaderForTest();

$serviceRouteLoader->loaderMap = array(
'my_route_provider_service' => $routeLoader
'my_route_provider_service' => $routeLoader,
);

// create a basic collection that will be returned
Expand Down Expand Up @@ -55,7 +54,7 @@ public function testExceptionOnInterfaceNotImplemented()

$serviceRouteLoader = new ObjectRouteLoaderForTest();
$serviceRouteLoader->loaderMap = array(
'any_service_name' => $routeLoader
'any_service_name' => $routeLoader,
);

$serviceRouteLoader->load('any_service_name', 'service');
Expand Down
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy