aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTristan Darricau <github@nicofuma.fr>2014-11-20 22:40:37 +0100
committerTristan Darricau <github@nicofuma.fr>2014-11-20 23:15:49 +0100
commit677b5b2cd4937ee6c777728082084c661223dee8 (patch)
tree4342890f46004943e15a2cfd8ccdd559619bb53c
parent93f61a4a7d34f8ad565bdc1605784284994ecdfc (diff)
downloadforums-677b5b2cd4937ee6c777728082084c661223dee8.tar
forums-677b5b2cd4937ee6c777728082084c661223dee8.tar.gz
forums-677b5b2cd4937ee6c777728082084c661223dee8.tar.bz2
forums-677b5b2cd4937ee6c777728082084c661223dee8.tar.xz
forums-677b5b2cd4937ee6c777728082084c661223dee8.zip
[ticket/12620] Fix rebase
PHPBB3-12620
-rw-r--r--phpBB/config/default/container/services.yml1
-rw-r--r--phpBB/phpbb/controller/helper.php5
-rw-r--r--phpBB/phpbb/di/container_builder.php2
-rw-r--r--phpBB/phpbb/di/extension/core.php40
-rw-r--r--phpBB/phpbb/extension/di/extension_base.php4
-rw-r--r--phpBB/phpbb/routing/router.php180
-rw-r--r--tests/avatar/driver/barfoo.php52
-rw-r--r--tests/avatar/driver/foobar.php52
-rw-r--r--tests/controller/common_helper_route.php6
-rw-r--r--tests/controller/controller_test.php4
-rw-r--r--tests/pagination/pagination_test.php10
11 files changed, 188 insertions, 168 deletions
diff --git a/phpBB/config/default/container/services.yml b/phpBB/config/default/container/services.yml
index 3f36a5178a..6cf9180cc0 100644
--- a/phpBB/config/default/container/services.yml
+++ b/phpBB/config/default/container/services.yml
@@ -157,6 +157,7 @@ services:
- @ext.manager
- %core.root_path%
- %core.php_ext%
+ - %core.environment%
router.listener:
class: Symfony\Component\HttpKernel\EventListener\RouterListener
diff --git a/phpBB/phpbb/controller/helper.php b/phpBB/phpbb/controller/helper.php
index cc327882e0..2bc8e6b9d0 100644
--- a/phpBB/phpbb/controller/helper.php
+++ b/phpBB/phpbb/controller/helper.php
@@ -41,8 +41,9 @@ class helper
protected $config;
/**
- * @var \phpbb\routing\router phpBB router
- */
+ * phpBB router
+ * @var \phpbb\routing\router
+ */
protected $router;
/* @var \phpbb\symfony_request */
diff --git a/phpBB/phpbb/di/container_builder.php b/phpBB/phpbb/di/container_builder.php
index 62bba5baf9..125ae28e9b 100644
--- a/phpBB/phpbb/di/container_builder.php
+++ b/phpBB/phpbb/di/container_builder.php
@@ -19,7 +19,7 @@ use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Dumper\PhpDumper;
use Symfony\Component\DependencyInjection\Loader\YamlFileLoader;
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBag;
-use Symfony\Component\HttpKernel\DependencyInjection\RegisterListenersPass;
+use Symfony\Component\EventDispatcher\DependencyInjection\RegisterListenersPass;
use Symfony\Component\HttpKernel\DependencyInjection\MergeExtensionConfigurationPass;
class container_builder
diff --git a/phpBB/phpbb/di/extension/core.php b/phpBB/phpbb/di/extension/core.php
index ce0d4a869c..72d46fb05b 100644
--- a/phpBB/phpbb/di/extension/core.php
+++ b/phpBB/phpbb/di/extension/core.php
@@ -25,29 +25,29 @@ use Symfony\Component\HttpKernel\DependencyInjection\Extension;
class core extends Extension
{
/**
- * Config path
- * @var string
- */
+ * Config path
+ * @var string
+ */
protected $config_path;
/**
- * Constructor
- *
- * @param string $config_path Config path
- */
+ * Constructor
+ *
+ * @param string $config_path Config path
+ */
public function __construct($config_path)
{
$this->config_path = $config_path;
}
/**
- * Loads a specific configuration.
- *
- * @param array $configs An array of configuration values
- * @param ContainerBuilder $container A ContainerBuilder instance
- *
- * @throws \InvalidArgumentException When provided tag is not defined in this extension
- */
+ * Loads a specific configuration.
+ *
+ * @param array $configs An array of configuration values
+ * @param ContainerBuilder $container A ContainerBuilder instance
+ *
+ * @throws \InvalidArgumentException When provided tag is not defined in this extension
+ */
public function load(array $configs, ContainerBuilder $container)
{
$loader = new YamlFileLoader($container, new FileLocator(phpbb_realpath($this->config_path)));
@@ -81,12 +81,12 @@ class core extends Extension
}
/**
- * Returns the recommended alias to use in XML.
- *
- * This alias is also the mandatory prefix to use when using YAML.
- *
- * @return string The alias
- */
+ * Returns the recommended alias to use in XML.
+ *
+ * This alias is also the mandatory prefix to use when using YAML.
+ *
+ * @return string The alias
+ */
public function getAlias()
{
return 'core';
diff --git a/phpBB/phpbb/extension/di/extension_base.php b/phpBB/phpbb/extension/di/extension_base.php
index 74026bd53a..30cc37dbb6 100644
--- a/phpBB/phpbb/extension/di/extension_base.php
+++ b/phpBB/phpbb/extension/di/extension_base.php
@@ -20,8 +20,8 @@ use Symfony\Component\DependencyInjection\Loader\YamlFileLoader;
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
/**
-* Container core extension
-*/
+ * Container core extension
+ */
class extension_base extends Extension
{
/**
diff --git a/phpBB/phpbb/routing/router.php b/phpBB/phpbb/routing/router.php
index f721837bba..0617e94c93 100644
--- a/phpBB/phpbb/routing/router.php
+++ b/phpBB/phpbb/routing/router.php
@@ -25,95 +25,119 @@ use Symfony\Component\Config\FileLocator;
use phpbb\extension\manager;
/**
-* Integration of all pieces of the routing system for easier use.
-*/
+ * Integration of all pieces of the routing system for easier use.
+ */
class router implements RouterInterface
{
/**
- * @var manager Extension manager
- */
+ * Extension manager
+ *
+ * @var manager
+ */
protected $extension_manager;
/**
- * @var string phpBB root path
- */
+ * phpBB root path
+ *
+ * @var string
+ */
protected $phpbb_root_path;
/**
- * @var string PHP file extensions
- */
+ * PHP file extensions
+ *
+ * @var string
+ */
protected $php_ext;
/**
- * @var array YAML file(s) containing route information
- */
+ * Name of the current environment
+ *
+ * @var string
+ */
+ protected $environment;
+
+ /**
+ * YAML file(s) containing route information
+ *
+ * @var array
+ */
protected $routing_files;
/**
- * @var \Symfony\Component\Routing\Matcher\UrlMatcherInterface|null
- */
+ * @var \Symfony\Component\Routing\Matcher\UrlMatcherInterface|null
+ */
protected $matcher;
/**
- * @var \Symfony\Component\Routing\Generator\UrlGeneratorInterface|null
- */
+ * @var \Symfony\Component\Routing\Generator\UrlGeneratorInterface|null
+ */
protected $generator;
/**
- * @var RequestContext
- */
+ * @var RequestContext
+ */
protected $context;
/**
- * @var RouteCollection|null
- */
+ * @var RouteCollection|null
+ */
protected $route_collection;
/**
- * Construct method
- *
- * @param manager $extension_manager The extension manager
- * @param string $phpbb_root_path phpBB root path
- * @param string $php_ext PHP file extension
- * @param array $routing_files Array of strings containing paths to YAML files holding route information
- */
- public function __construct(manager $extension_manager, $phpbb_root_path, $php_ext, $routing_files = array())
+ * Construct method
+ *
+ * @param manager $extension_manager Extension manager
+ * @param string $phpbb_root_path phpBB root path
+ * @param string $php_ext PHP file extension
+ * @param string $environment Name of the current environment
+ * @param array $routing_files Array of strings containing paths to YAML files holding route information
+ */
+ public function __construct(manager $extension_manager, $phpbb_root_path, $php_ext, $environment, $routing_files = array())
{
$this->extension_manager = $extension_manager;
$this->routing_files = $routing_files;
$this->phpbb_root_path = $phpbb_root_path;
$this->php_ext = $php_ext;
+ $this->environment = $environment;
$this->context = new RequestContext();
}
/**
- * Find the list of routing files
- *
- * @param \phpbb\finder $finder
- * @return router
- */
- public function find_routing_files(\phpbb\finder $finder)
+ * Find the list of routing files
+ *
+ * @param array $paths Array of paths where to look for routing files.
+ * @return null
+ */
+ public function find_routing_files(array $paths)
{
- if ($this->routing_files === null || empty($this->routing_files))
+ $this->routing_files = array($this->phpbb_root_path . 'config/' . $this->environment . '/routing/environment.yml');
+ foreach ($paths as $path)
{
- // We hardcode the path to the core config directory
- // because the finder cannot find it
- $this->routing_files = array_merge($this->routing_files, array('config/routing.yml'), array_keys($finder
- ->directory('/config')
- ->suffix('routing.yml')
- ->find()
- ));
+ if (file_exists($path . 'config/' . $this->environment . '/routing/environment.yml'))
+ {
+ $this->routing_files[] = $path . 'config/' . $this->environment . '/routing/environment.yml';
+ }
+ else if (!is_dir($path . 'config/' . $this->environment))
+ {
+ if (file_exists($path . 'config/default/routing/environment.yml'))
+ {
+ $this->routing_files[] = $path . 'config/default/routing/environment.yml';
+ }
+ else if (!is_dir($path . 'config/default/routing') && file_exists($path . 'config/routing.yml'))
+ {
+ $this->routing_files[] = $path . 'config/routing.yml';
+ }
+ }
}
-
- return $this;
}
/**
- * Find a list of controllers
- *
- * @param string $base_path Base path to prepend to file paths
- * @return router
- */
+ * Find a list of controllers
+ *
+ * @param string $base_path Base path to prepend to file paths
+ * @return router
+ */
public function find($base_path = '')
{
if ($this->route_collection === null || $this->route_collection->count() === 0)
@@ -130,15 +154,15 @@ class router implements RouterInterface
}
/**
- * Get the list of routes
- *
- * @return RouteCollection Get the route collection
- */
+ * Get the list of routes
+ *
+ * @return RouteCollection Get the route collection
+ */
public function get_routes()
{
if ($this->route_collection == null || empty($this->routing_files))
{
- $this->find_routing_files($this->extension_manager->get_finder())
+ $this->find_routing_files($this->extension_manager->all_enabled())
->find($this->phpbb_root_path);
}
@@ -146,16 +170,16 @@ class router implements RouterInterface
}
/**
- * {@inheritdoc}
- */
+ * {@inheritdoc}
+ */
public function getRouteCollection()
{
return $this->get_routes();
}
/**
- * {@inheritdoc}
- */
+ * {@inheritdoc}
+ */
public function setContext(RequestContext $context)
{
$this->context = $context;
@@ -171,34 +195,34 @@ class router implements RouterInterface
}
/**
- * {@inheritdoc}
- */
+ * {@inheritdoc}
+ */
public function getContext()
{
return $this->context;
}
/**
- * {@inheritdoc}
- */
+ * {@inheritdoc}
+ */
public function generate($name, $parameters = array(), $referenceType = self::ABSOLUTE_PATH)
{
return $this->get_generator()->generate($name, $parameters, $referenceType);
}
/**
- * {@inheritdoc}
- */
+ * {@inheritdoc}
+ */
public function match($pathinfo)
{
return $this->get_matcher()->match($pathinfo);
}
/**
- * Gets the UrlMatcher instance associated with this Router.
- *
- * @return \Symfony\Component\Routing\Matcher\UrlMatcherInterface A UrlMatcherInterface instance
- */
+ * Gets the UrlMatcher instance associated with this Router.
+ *
+ * @return \Symfony\Component\Routing\Matcher\UrlMatcherInterface A UrlMatcherInterface instance
+ */
public function get_matcher()
{
if ($this->matcher !== null)
@@ -218,8 +242,8 @@ class router implements RouterInterface
return $this->matcher;
}
/**
- * Creates a new dumped URL Matcher (dump it if necessary)
- */
+ * Creates a new dumped URL Matcher (dump it if necessary)
+ */
protected function create_dumped_url_matcher()
{
if (!file_exists($this->phpbb_root_path . 'cache/url_matcher.' . $this->php_ext))
@@ -240,18 +264,18 @@ class router implements RouterInterface
}
/**
- * Creates a new URL Matcher
- */
+ * Creates a new URL Matcher
+ */
protected function create_new_url_matcher()
{
$this->matcher = new UrlMatcher($this->get_routes(), $this->context);
}
/**
- * Gets the UrlGenerator instance associated with this Router.
- *
- * @return \Symfony\Component\Routing\Generator\UrlGeneratorInterface A UrlGeneratorInterface instance
- */
+ * Gets the UrlGenerator instance associated with this Router.
+ *
+ * @return \Symfony\Component\Routing\Generator\UrlGeneratorInterface A UrlGeneratorInterface instance
+ */
public function get_generator()
{
if ($this->generator !== null)
@@ -272,8 +296,8 @@ class router implements RouterInterface
}
/**
- * Creates a new dumped URL Generator (dump it if necessary)
- */
+ * Creates a new dumped URL Generator (dump it if necessary)
+ */
protected function create_dumped_url_generator()
{
if (!file_exists($this->phpbb_root_path . 'cache/url_generator.' . $this->php_ext))
@@ -294,8 +318,8 @@ class router implements RouterInterface
}
/**
- * Creates a new URL Generator
- */
+ * Creates a new URL Generator
+ */
protected function create_new_url_generator()
{
$this->generator = new UrlGenerator($this->get_routes(), $this->context);
diff --git a/tests/avatar/driver/barfoo.php b/tests/avatar/driver/barfoo.php
index 0bf30b8a91..067bb3ef97 100644
--- a/tests/avatar/driver/barfoo.php
+++ b/tests/avatar/driver/barfoo.php
@@ -1,26 +1,26 @@
-<?php
-
-namespace phpbb\avatar\driver;
-
-class barfoo extends \phpbb\avatar\driver\driver
-{
- public function get_data($row)
- {
- return array();
- }
-
- public function prepare_form($request, $template, $user, $row, &$error)
- {
- return false;
- }
-
- public function process_form($request, $template, $user, $row, &$error)
- {
- return false;
- }
-
- public function get_template_name()
- {
- return 'barfoo.html';
- }
-}
+<?php
+
+namespace phpbb\avatar\driver;
+
+class barfoo extends \phpbb\avatar\driver\driver
+{
+ public function get_data($row)
+ {
+ return array();
+ }
+
+ public function prepare_form($request, $template, $user, $row, &$error)
+ {
+ return false;
+ }
+
+ public function process_form($request, $template, $user, $row, &$error)
+ {
+ return false;
+ }
+
+ public function get_template_name()
+ {
+ return 'barfoo.html';
+ }
+}
diff --git a/tests/avatar/driver/foobar.php b/tests/avatar/driver/foobar.php
index aabdaf5ac4..16d50ccad4 100644
--- a/tests/avatar/driver/foobar.php
+++ b/tests/avatar/driver/foobar.php
@@ -1,26 +1,26 @@
-<?php
-
-namespace phpbb\avatar\driver;
-
-class foobar extends \phpbb\avatar\driver\driver
-{
- public function get_data($row)
- {
- return array();
- }
-
- public function prepare_form($request, $template, $user, $row, &$error)
- {
- return false;
- }
-
- public function process_form($request, $template, $user, $row, &$error)
- {
- return false;
- }
-
- public function get_template_name()
- {
- return 'foobar.html';
- }
-}
+<?php
+
+namespace phpbb\avatar\driver;
+
+class foobar extends \phpbb\avatar\driver\driver
+{
+ public function get_data($row)
+ {
+ return array();
+ }
+
+ public function prepare_form($request, $template, $user, $row, &$error)
+ {
+ return false;
+ }
+
+ public function process_form($request, $template, $user, $row, &$error)
+ {
+ return false;
+ }
+
+ public function get_template_name()
+ {
+ return 'foobar.html';
+ }
+}
diff --git a/tests/controller/common_helper_route.php b/tests/controller/common_helper_route.php
index 5baa846ec3..19d40cf071 100644
--- a/tests/controller/common_helper_route.php
+++ b/tests/controller/common_helper_route.php
@@ -113,8 +113,8 @@ abstract class phpbb_controller_common_helper_route extends phpbb_test_case
)
);
- $this->router = new phpbb_mock_router($this->extension_manager, dirname(__FILE__) . '/', 'php');
- $this->router->find_routing_files($finder);
+ $this->router = new phpbb_mock_router($this->extension_manager, dirname(__FILE__) . '/', 'php', PHPBB_ENVIRONMENT);
+ $this->router->find_routing_files($this->extension_manager->all_enabled());
$this->router->find(dirname(__FILE__) . '/');
// Set correct current phpBB root path
$this->root_path = $this->get_phpbb_root_path();
@@ -319,7 +319,7 @@ abstract class phpbb_controller_common_helper_route extends phpbb_test_case
$this->helper = new phpbb_mock_controller_helper($this->template, $this->user, $this->config, $this->router, $this->symfony_request, $this->request, $this->filesystem, $this->root_path, 'php', dirname(__FILE__) . '/');
$this->assertEquals($expected, $this->helper->route($route, $params, $is_amp, $session_id, UrlGeneratorInterface::NETWORK_PATH), $description);
}
-//TODO
+
public function helper_url_data_absolute_with_rewrite()
{
return array(
diff --git a/tests/controller/controller_test.php b/tests/controller/controller_test.php
index 637e9685e6..354a902831 100644
--- a/tests/controller/controller_test.php
+++ b/tests/controller/controller_test.php
@@ -40,8 +40,8 @@ class phpbb_controller_controller_test extends phpbb_test_case
public function test_router_find_files()
{
- $router = new \phpbb\routing\router($this->extension_manager, dirname(__FILE__) . '/', 'php');
- $router->find_routing_files($this->extension_manager->get_finder());
+ $router = new \phpbb\routing\router($this->extension_manager, dirname(__FILE__) . '/', 'php', PHPBB_ENVIRONMENT);
+ $router->find_routing_files($this->extension_manager->all_enabled());
$routes = $router->find(__DIR__)->get_routes();
// This will need to be updated if any new routes are defined
diff --git a/tests/pagination/pagination_test.php b/tests/pagination/pagination_test.php
index 04f7b807a7..1b9e8c751c 100644
--- a/tests/pagination/pagination_test.php
+++ b/tests/pagination/pagination_test.php
@@ -36,16 +36,10 @@ class phpbb_pagination_pagination_test extends phpbb_template_template_test_case
$filesystem = new \phpbb\filesystem();
$manager = new phpbb_mock_extension_manager(dirname(__FILE__) . '/', array());
- $finder = new \phpbb\finder(
- $filesystem,
- dirname(__FILE__) . '/',
- new phpbb_mock_cache()
- );
- $finder->set_extensions(array_keys($manager->all_enabled()));
$this->config = new \phpbb\config\config(array('enable_mod_rewrite' => '1'));
- $router = new phpbb_mock_router($manager, dirname(__FILE__) . '/', 'php');
- $router->find_routing_files($finder);
+ $router = new phpbb_mock_router($manager, dirname(__FILE__) . '/', 'php', PHPBB_ENVIRONMENT);
+ $router->find_routing_files($manager->all_enabled());
$router->find(dirname(__FILE__) . '/');
$request = new phpbb_mock_request();