aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB/includes/functions_url_matcher.php
diff options
context:
space:
mode:
authorDavid King <imkingdavid@gmail.com>2012-11-14 15:56:07 -0500
committerDavid King <imkingdavid@gmail.com>2012-11-16 17:05:41 -0500
commit196c2d4bc346ab6a31fd0b752c788e37cf39459d (patch)
treeaf131b79f9fb683ce240db6bcf69063587d59a1d /phpBB/includes/functions_url_matcher.php
parent269a56e2c3817cc27f2b21b9eb864c4f2452bc13 (diff)
downloadforums-196c2d4bc346ab6a31fd0b752c788e37cf39459d.tar
forums-196c2d4bc346ab6a31fd0b752c788e37cf39459d.tar.gz
forums-196c2d4bc346ab6a31fd0b752c788e37cf39459d.tar.bz2
forums-196c2d4bc346ab6a31fd0b752c788e37cf39459d.tar.xz
forums-196c2d4bc346ab6a31fd0b752c788e37cf39459d.zip
[feature/controller] Move new functions to their own file
PHPBB3-10864
Diffstat (limited to 'phpBB/includes/functions_url_matcher.php')
-rw-r--r--phpBB/includes/functions_url_matcher.php68
1 files changed, 68 insertions, 0 deletions
diff --git a/phpBB/includes/functions_url_matcher.php b/phpBB/includes/functions_url_matcher.php
new file mode 100644
index 0000000000..0a6e90703c
--- /dev/null
+++ b/phpBB/includes/functions_url_matcher.php
@@ -0,0 +1,68 @@
+<?php
+/**
+*
+* @package phpBB3
+* @copyright (c) 2005 phpBB Group
+* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
+*
+*/
+
+use Symfony\Component\Routing\Matcher\Dumper\PhpMatcherDumper;
+use Symfony\Component\Routing\RequestContext;
+
+/**
+* @ignore
+*/
+if (!defined('IN_PHPBB'))
+{
+ exit;
+}
+
+/**
+* Create and/or return the cached phpbb_url_matcher class
+*
+* If the class already exists, it instantiates it
+*
+* @param phpbb_extension_finder $finder Extension finder
+* @param RequestContext $context Symfony RequestContext object
+* @param string $root_path Root path
+* @param string $php_ext PHP extension
+* @return phpbb_url_matcher
+*/
+function phpbb_create_url_matcher(phpbb_extension_finder $finder, RequestContext $context, $root_path, $php_ext)
+{
+ $matcher = phpbb_load_url_matcher($finder, $context, $root_path, $php_ext);
+ if ($matcher === false)
+ {
+ $provider = new phpbb_controller_provider();
+ $dumper = new PhpMatcherDumper($provider->get_paths($finder)->find());
+ $cached_url_matcher_dump = $dumper->dump(array(
+ 'class' => 'phpbb_url_matcher',
+ ));
+
+ file_put_contents($root_path . 'cache/url_matcher' . $php_ext, $cached_url_matcher_dump);
+ return phpbb_load_url_matcher($finder, $context, $root_path, $php_ext);
+ }
+
+ return $matcher;
+}
+
+/**
+* Load the cached phpbb_url_matcher class
+*
+* @param phpbb_extension_finder $finder Extension finder
+* @param RequestContext $context Symfony RequestContext object
+* @param string $root_path Root path
+* @param string $php_ext PHP extension
+* @return phpbb_url_matcher|bool False if the file doesn't exist
+*/
+function phpbb_load_url_matcher(phpbb_extension_finder $finder, RequestContext $context, $root_path, $php_ext)
+{
+ if (file_exists($root_path . 'cache/url_matcher' . $php_ext))
+ {
+ include($root_path . 'cache/url_matcher' . $php_ext);
+ return new phpbb_url_matcher($context);
+ }
+
+ return false;
+}