aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTristan Darricau <github@nicofuma.fr>2014-09-05 16:33:57 +0200
committerTristan Darricau <github@nicofuma.fr>2014-11-20 20:15:45 +0100
commit014eed385bf761d9e3f0992835f44f58bf055afd (patch)
tree7c1e824a9346efd0dbe05c732926ae9fd006cd0b
parent7cd0fd83b8047f40edfb69a427b14997801ef25b (diff)
downloadforums-014eed385bf761d9e3f0992835f44f58bf055afd.tar
forums-014eed385bf761d9e3f0992835f44f58bf055afd.tar.gz
forums-014eed385bf761d9e3f0992835f44f58bf055afd.tar.bz2
forums-014eed385bf761d9e3f0992835f44f58bf055afd.tar.xz
forums-014eed385bf761d9e3f0992835f44f58bf055afd.zip
[ticket/12620] Add support of the environments for the ext routing files
PHPBB3-12620
-rwxr-xr-xphpBB/bin/phpbbcli.php6
-rw-r--r--phpBB/includes/functions_url_matcher.php4
-rw-r--r--tests/controller/common_helper_route.php6
-rw-r--r--tests/controller/controller_test.php8
-rw-r--r--tests/controller/ext/vendor2/bar/config/production/routing.yml3
-rw-r--r--tests/controller/ext/vendor2/bar/config/services.yml3
-rw-r--r--tests/controller/ext/vendor2/bar/controller.php18
7 files changed, 40 insertions, 8 deletions
diff --git a/phpBB/bin/phpbbcli.php b/phpBB/bin/phpbbcli.php
index ca425ad0c4..14681e25ee 100755
--- a/phpBB/bin/phpbbcli.php
+++ b/phpBB/bin/phpbbcli.php
@@ -21,6 +21,12 @@ if (php_sapi_name() != 'cli')
}
define('IN_PHPBB', true);
+
+if (!defined('PHPBB_ENVIRONMENT'))
+{
+ @define('PHPBB_ENVIRONMENT', 'production');
+}
+
$phpbb_root_path = __DIR__ . '/../';
$phpEx = substr(strrchr(__FILE__, '.'), 1);
require($phpbb_root_path . 'includes/startup.' . $phpEx);
diff --git a/phpBB/includes/functions_url_matcher.php b/phpBB/includes/functions_url_matcher.php
index b965046aad..3d977a5daf 100644
--- a/phpBB/includes/functions_url_matcher.php
+++ b/phpBB/includes/functions_url_matcher.php
@@ -58,7 +58,7 @@ function phpbb_get_url_matcher(\phpbb\extension\manager $manager, RequestContext
function phpbb_create_dumped_url_matcher(\phpbb\extension\manager $manager, $root_path, $php_ext)
{
$provider = new \phpbb\controller\provider();
- $provider->find_routing_files($manager->get_finder());
+ $provider->find_routing_files($manager->all_enabled());
$routes = $provider->find($root_path)->get_routes();
$dumper = new PhpMatcherDumper($routes);
$cached_url_matcher_dump = $dumper->dump(array(
@@ -78,7 +78,7 @@ function phpbb_create_dumped_url_matcher(\phpbb\extension\manager $manager, $roo
function phpbb_create_url_matcher(\phpbb\extension\manager $manager, RequestContext $context, $root_path)
{
$provider = new \phpbb\controller\provider();
- $provider->find_routing_files($manager->get_finder());
+ $provider->find_routing_files($manager->all_enabled());
$routes = $provider->find($root_path)->get_routes();
return new UrlMatcher($routes, $context);
}
diff --git a/tests/controller/common_helper_route.php b/tests/controller/common_helper_route.php
index 028a73d70d..5baa846ec3 100644
--- a/tests/controller/common_helper_route.php
+++ b/tests/controller/common_helper_route.php
@@ -113,12 +113,6 @@ abstract class phpbb_controller_common_helper_route extends phpbb_test_case
)
);
- $finder = new \phpbb\finder(
- new \phpbb\filesystem(),
- dirname(__FILE__) . '/',
- new phpbb_mock_cache()
- );
- $finder->set_extensions(array_keys($this->extension_manager->all_enabled()));
$this->router = new phpbb_mock_router($this->extension_manager, dirname(__FILE__) . '/', 'php');
$this->router->find_routing_files($finder);
$this->router->find(dirname(__FILE__) . '/');
diff --git a/tests/controller/controller_test.php b/tests/controller/controller_test.php
index cd90dda751..637e9685e6 100644
--- a/tests/controller/controller_test.php
+++ b/tests/controller/controller_test.php
@@ -30,6 +30,11 @@ class phpbb_controller_controller_test extends phpbb_test_case
'ext_active' => '1',
'ext_path' => 'ext/vendor2/foo/',
),
+ 'vendor2/bar' => array(
+ 'ext_name' => 'vendor2/bar',
+ 'ext_active' => '1',
+ 'ext_path' => 'ext/vendor2/bar/',
+ ),
));
}
@@ -49,6 +54,9 @@ class phpbb_controller_controller_test extends phpbb_test_case
$this->assertInstanceOf('Symfony\Component\Routing\Route', $routes->get('controller2'));
$this->assertEquals('/foo/bar', $routes->get('controller2')->getPath());
+ $this->assertInstanceOf('Symfony\Component\Routing\Route', $routes->get('controller3'));
+ $this->assertEquals('/bar', $routes->get('controller3')->getPath());
+
$this->assertNull($routes->get('controller_noroute'));
}
diff --git a/tests/controller/ext/vendor2/bar/config/production/routing.yml b/tests/controller/ext/vendor2/bar/config/production/routing.yml
new file mode 100644
index 0000000000..85c93b453f
--- /dev/null
+++ b/tests/controller/ext/vendor2/bar/config/production/routing.yml
@@ -0,0 +1,3 @@
+controller3:
+ pattern: /bar
+ defaults: { _controller: bar.controller:handle }
diff --git a/tests/controller/ext/vendor2/bar/config/services.yml b/tests/controller/ext/vendor2/bar/config/services.yml
new file mode 100644
index 0000000000..05a8a1994d
--- /dev/null
+++ b/tests/controller/ext/vendor2/bar/config/services.yml
@@ -0,0 +1,3 @@
+services:
+ bar.controller:
+ class: bar\controller
diff --git a/tests/controller/ext/vendor2/bar/controller.php b/tests/controller/ext/vendor2/bar/controller.php
new file mode 100644
index 0000000000..ad35f5a051
--- /dev/null
+++ b/tests/controller/ext/vendor2/bar/controller.php
@@ -0,0 +1,18 @@
+<?php
+
+namespace bar;
+
+use Symfony\Component\HttpFoundation\Response;
+
+class controller
+{
+ /**
+ * Handle method
+ *
+ * @return null
+ */
+ public function handle()
+ {
+ return new Response('Test', 200);
+ }
+}