[ Index ]

PHP Cross Reference of phpBB-3.1.12-deutsch

title

Body

[close]

/includes/ -> functions_url_matcher.php (source)

   1  <?php
   2  /**
   3  *
   4  * This file is part of the phpBB Forum Software package.
   5  *
   6  * @copyright (c) phpBB Limited <https://www.phpbb.com>
   7  * @license GNU General Public License, version 2 (GPL-2.0)
   8  *
   9  * For full copyright and license information, please see
  10  * the docs/CREDITS.txt file.
  11  *
  12  */
  13  
  14  use Symfony\Component\Routing\Matcher\Dumper\PhpMatcherDumper;
  15  use Symfony\Component\Routing\Matcher\UrlMatcher;
  16  use Symfony\Component\Routing\RequestContext;
  17  
  18  /**
  19  * @ignore
  20  */
  21  if (!defined('IN_PHPBB'))
  22  {
  23      exit;
  24  }
  25  
  26  /**
  27  * Create a new UrlMatcher class and dump it into the cache file
  28  *
  29  * @param \phpbb\extension\manager $manager Extension manager
  30  * @param RequestContext $context Symfony RequestContext object
  31  * @param string $root_path Root path
  32  * @param string $php_ext PHP file extension
  33  * @return null
  34  */
  35  function phpbb_get_url_matcher(\phpbb\extension\manager $manager, RequestContext $context, $root_path, $php_ext)
  36  {
  37      if (defined('DEBUG'))
  38      {
  39          return phpbb_create_url_matcher($manager, $context, $root_path);
  40      }
  41  
  42      if (!phpbb_url_matcher_dumped($root_path, $php_ext))
  43      {
  44          phpbb_create_dumped_url_matcher($manager, $root_path, $php_ext);
  45      }
  46  
  47      return phpbb_load_url_matcher($context, $root_path, $php_ext);
  48  }
  49  
  50  /**
  51  * Create a new UrlMatcher class and dump it into the cache file
  52  *
  53  * @param \phpbb\extension\manager $manager Extension manager
  54  * @param string $root_path Root path
  55  * @param string $php_ext PHP file extension
  56  * @return null
  57  */
  58  function phpbb_create_dumped_url_matcher(\phpbb\extension\manager $manager, $root_path, $php_ext)
  59  {
  60      $provider = new \phpbb\controller\provider();
  61      $provider->find_routing_files($manager->get_finder());
  62      $routes = $provider->find($root_path)->get_routes();
  63      $dumper = new PhpMatcherDumper($routes);
  64      $cached_url_matcher_dump = $dumper->dump(array(
  65          'class'            => 'phpbb_url_matcher',
  66      ));
  67  
  68      file_put_contents($root_path . 'cache/url_matcher.' . $php_ext, $cached_url_matcher_dump);
  69  }
  70  
  71  /**
  72  * Create a non-cached UrlMatcher
  73  *
  74  * @param \phpbb\extension\manager $manager Extension manager
  75  * @param RequestContext $context Symfony RequestContext object
  76  * @return UrlMatcher
  77  */
  78  function phpbb_create_url_matcher(\phpbb\extension\manager $manager, RequestContext $context, $root_path)
  79  {
  80      $provider = new \phpbb\controller\provider();
  81      $provider->find_routing_files($manager->get_finder());
  82      $routes = $provider->find($root_path)->get_routes();
  83      return new UrlMatcher($routes, $context);
  84  }
  85  
  86  /**
  87  * Load the cached phpbb_url_matcher class
  88  *
  89  * @param RequestContext $context Symfony RequestContext object
  90  * @param string $root_path Root path
  91  * @param string $php_ext PHP file extension
  92  * @return phpbb_url_matcher
  93  */
  94  function phpbb_load_url_matcher(RequestContext $context, $root_path, $php_ext)
  95  {
  96      require($root_path . 'cache/url_matcher.' . $php_ext);
  97      return new phpbb_url_matcher($context);
  98  }
  99  
 100  /**
 101  * Determine whether we have our dumped URL matcher
 102  *
 103  * The class is automatically dumped to the cache directory
 104  *
 105  * @param string $root_path Root path
 106  * @param string $php_ext PHP file extension
 107  * @return bool True if it exists, false if not
 108  */
 109  function phpbb_url_matcher_dumped($root_path, $php_ext)
 110  {
 111      return file_exists($root_path . 'cache/url_matcher.' . $php_ext);
 112  }


Generated: Thu Jan 11 00:25:41 2018 Cross-referenced by PHPXref 0.7.1