[feature/controller] Rename get_paths to import_paths_from_finder

Also removed unused variable from url_matcher function

PHPBB3-10864
This commit is contained in:
David King 2012-11-15 13:59:30 -05:00
parent b4eff4f06a
commit db1d49d559
2 changed files with 9 additions and 21 deletions

View file

@ -39,7 +39,7 @@ class phpbb_controller_provider
*/ */
public function __construct($routing_paths = array()) public function __construct($routing_paths = array())
{ {
$this->set_paths($routing_paths); $this->routing_paths = $routing_paths;
} }
/** /**
@ -48,28 +48,16 @@ class phpbb_controller_provider
* *
* @return The current instance of this object for method chaining * @return The current instance of this object for method chaining
*/ */
public function get_paths(phpbb_extension_finder $finder) public function import_paths_from_finder(phpbb_extension_finder $finder)
{ {
// We hardcode the path to the core config directory // We hardcode the path to the core config directory
// because the finder cannot find it // because the finder cannot find it
$this->set_paths(array_merge(array('config'), array_map('dirname', array_keys($finder $this->routing_paths = array_merge(array('config'), array_map('dirname', array_keys($finder
->directory('config') ->directory('config')
->prefix('routing') ->prefix('routing')
->suffix('yml') ->suffix('yml')
->find() ->find()
)))); )));
return $this;
}
/**
* Set the $routing_paths property with a given list of paths
*
* @return The current instance of this object for method chaining
*/
public function set_paths(array $paths)
{
$this->routing_paths = $paths;
return $this; return $this;
} }

View file

@ -37,7 +37,7 @@ function phpbb_get_url_matcher(phpbb_extension_finder $finder, RequestContext $c
if (!phpbb_url_matcher_dumped($root_path, $php_ext)) if (!phpbb_url_matcher_dumped($root_path, $php_ext))
{ {
phpbb_create_dumped_url_matcher($finder, $context, $root_path, $php_ext); phpbb_create_dumped_url_matcher($finder, $root_path, $php_ext);
} }
return phpbb_load_url_matcher($context, $root_path, $php_ext); return phpbb_load_url_matcher($context, $root_path, $php_ext);
@ -47,15 +47,14 @@ function phpbb_get_url_matcher(phpbb_extension_finder $finder, RequestContext $c
* Create a new UrlMatcher class and dump it into the cache file * Create a new UrlMatcher class and dump it into the cache file
* *
* @param phpbb_extension_finder $finder Extension finder * @param phpbb_extension_finder $finder Extension finder
* @param RequestContext $context Symfony RequestContext object
* @param string $root_path Root path * @param string $root_path Root path
* @param string $php_ext PHP extension * @param string $php_ext PHP extension
* @return null * @return null
*/ */
function phpbb_create_dumped_url_matcher(phpbb_extension_finder $finder, RequestContext $context, $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->get_paths($finder)->find(); $routes = $provider->import_paths_from_finder($finder)->find();
$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',
@ -74,7 +73,8 @@ function phpbb_create_dumped_url_matcher(phpbb_extension_finder $finder, Request
function phpbb_create_url_matcher(phpbb_extension_finder $finder, RequestContext $context) function phpbb_create_url_matcher(phpbb_extension_finder $finder, RequestContext $context)
{ {
$provider = new phpbb_controller_provider(); $provider = new phpbb_controller_provider();
return new UrlMatcher($provider->get_paths($finder)->find(), $context); $routes = $provider->import_paths_from_finder($finder)->find();
return new UrlMatcher($routes, $context);
} }
/** /**