mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-10 05:18:52 +00:00
[ticket/11948] Allow resource importing for routing
PHPBB3-11948
This commit is contained in:
parent
bd86dea16c
commit
51561ed538
4 changed files with 12 additions and 9 deletions
|
@ -32,7 +32,7 @@ function phpbb_get_url_matcher(\phpbb\extension\finder $finder, RequestContext $
|
||||||
{
|
{
|
||||||
if (defined('DEBUG'))
|
if (defined('DEBUG'))
|
||||||
{
|
{
|
||||||
return phpbb_create_url_matcher($finder, $context);
|
return phpbb_create_url_matcher($finder, $context, $root_path);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!phpbb_url_matcher_dumped($root_path, $php_ext))
|
if (!phpbb_url_matcher_dumped($root_path, $php_ext))
|
||||||
|
@ -54,7 +54,7 @@ function phpbb_get_url_matcher(\phpbb\extension\finder $finder, RequestContext $
|
||||||
function phpbb_create_dumped_url_matcher(\phpbb\extension\finder $finder, $root_path, $php_ext)
|
function phpbb_create_dumped_url_matcher(\phpbb\extension\finder $finder, $root_path, $php_ext)
|
||||||
{
|
{
|
||||||
$provider = new \phpbb\controller\provider();
|
$provider = new \phpbb\controller\provider();
|
||||||
$routes = $provider->import_paths_from_finder($finder)->find();
|
$routes = $provider->import_paths_from_finder($finder)->find($root_path);
|
||||||
$dumper = new PhpMatcherDumper($routes);
|
$dumper = new PhpMatcherDumper($routes);
|
||||||
$cached_url_matcher_dump = $dumper->dump(array(
|
$cached_url_matcher_dump = $dumper->dump(array(
|
||||||
'class' => 'phpbb_url_matcher',
|
'class' => 'phpbb_url_matcher',
|
||||||
|
@ -70,10 +70,10 @@ function phpbb_create_dumped_url_matcher(\phpbb\extension\finder $finder, $root_
|
||||||
* @param RequestContext $context Symfony RequestContext object
|
* @param RequestContext $context Symfony RequestContext object
|
||||||
* @return UrlMatcher
|
* @return UrlMatcher
|
||||||
*/
|
*/
|
||||||
function phpbb_create_url_matcher(\phpbb\extension\finder $finder, RequestContext $context)
|
function phpbb_create_url_matcher(\phpbb\extension\finder $finder, RequestContext $context, $root_path)
|
||||||
{
|
{
|
||||||
$provider = new \phpbb\controller\provider();
|
$provider = new \phpbb\controller\provider();
|
||||||
$routes = $provider->import_paths_from_finder($finder)->find();
|
$routes = $provider->import_paths_from_finder($finder)->find($root_path);
|
||||||
return new UrlMatcher($routes, $context);
|
return new UrlMatcher($routes, $context);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -56,8 +56,7 @@ class provider
|
||||||
// because the finder cannot find it
|
// because the finder cannot find it
|
||||||
$this->routing_files = array_merge(array('config/routing.yml'), array_keys($finder
|
$this->routing_files = array_merge(array('config/routing.yml'), array_keys($finder
|
||||||
->directory('config')
|
->directory('config')
|
||||||
->prefix('routing')
|
->suffix('routing.yml')
|
||||||
->suffix('.yml')
|
|
||||||
->find()
|
->find()
|
||||||
));
|
));
|
||||||
|
|
||||||
|
@ -75,8 +74,8 @@ class provider
|
||||||
$routes = new RouteCollection;
|
$routes = new RouteCollection;
|
||||||
foreach ($this->routing_files as $file_path)
|
foreach ($this->routing_files as $file_path)
|
||||||
{
|
{
|
||||||
$loader = new YamlFileLoader(new FileLocator(dirname($base_path . $file_path)));
|
$loader = new YamlFileLoader(new FileLocator($base_path));
|
||||||
$routes->addCollection($loader->load(basename($file_path)));
|
$routes->addCollection($loader->load($file_path));
|
||||||
}
|
}
|
||||||
|
|
||||||
return $routes;
|
return $routes;
|
||||||
|
|
|
@ -34,7 +34,7 @@ class phpbb_controller_controller_test extends phpbb_test_case
|
||||||
$provider = new \phpbb\controller\provider;
|
$provider = new \phpbb\controller\provider;
|
||||||
$routes = $provider
|
$routes = $provider
|
||||||
->import_paths_from_finder($this->extension_manager->get_finder())
|
->import_paths_from_finder($this->extension_manager->get_finder())
|
||||||
->find('./tests/controller/');
|
->find(__DIR__);
|
||||||
|
|
||||||
// This will need to be updated if any new routes are defined
|
// This will need to be updated if any new routes are defined
|
||||||
$this->assertEquals(3, sizeof($routes));
|
$this->assertEquals(3, sizeof($routes));
|
||||||
|
|
|
@ -1,3 +1,7 @@
|
||||||
controller1:
|
controller1:
|
||||||
pattern: /foo
|
pattern: /foo
|
||||||
defaults: { _controller: foo.controller:handle }
|
defaults: { _controller: foo.controller:handle }
|
||||||
|
|
||||||
|
include_controller2:
|
||||||
|
resource: "routing_2.yml"
|
||||||
|
prefix: /foo
|
||||||
|
|
Loading…
Add table
Reference in a new issue