/**
* Create a non-cached UrlMatcher
*
* @param \phpbb\extension\manager $manager Extension manager
* @param RequestContext $context Symfony RequestContext object
* @return UrlMatcher
*/
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());
    $routes = $provider->find($root_path)->get_routes();
    return new UrlMatcher($routes, $context);
}
Ejemplo n.º 2
0
 public function test_provider()
 {
     $provider = new \phpbb\controller\provider();
     $provider->find_routing_files($this->extension_manager->get_finder());
     $routes = $provider->find(__DIR__)->get_routes();
     // This will need to be updated if any new routes are defined
     $this->assertInstanceOf('Symfony\\Component\\Routing\\Route', $routes->get('core_controller'));
     $this->assertEquals('/core_foo', $routes->get('core_controller')->getPath());
     $this->assertInstanceOf('Symfony\\Component\\Routing\\Route', $routes->get('controller1'));
     $this->assertEquals('/foo', $routes->get('controller1')->getPath());
     $this->assertInstanceOf('Symfony\\Component\\Routing\\Route', $routes->get('controller2'));
     $this->assertEquals('/foo/bar', $routes->get('controller2')->getPath());
     $this->assertNull($routes->get('controller_noroute'));
 }
Ejemplo n.º 3
0
 public function setUp()
 {
     parent::setUp();
     global $phpbb_dispatcher;
     $phpbb_dispatcher = new phpbb_mock_event_dispatcher();
     $this->user = $this->getMock('\\phpbb\\user', array(), array('\\phpbb\\datetime'));
     $this->user->expects($this->any())->method('lang')->will($this->returnCallback(array($this, 'return_callback_implode')));
     $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'));
     $provider = new \phpbb\controller\provider();
     $provider->find_routing_files($finder);
     $provider->find(dirname(__FILE__) . '/');
     $request = new phpbb_mock_request();
     $request->overwrite('SCRIPT_NAME', '/app.php', \phpbb\request\request_interface::SERVER);
     $request->overwrite('SCRIPT_FILENAME', 'app.php', \phpbb\request\request_interface::SERVER);
     $request->overwrite('REQUEST_URI', '/app.php', \phpbb\request\request_interface::SERVER);
     $symfony_request = new \phpbb\symfony_request($request);
     $this->helper = new phpbb_mock_controller_helper($this->template, $this->user, $this->config, $provider, $manager, $symfony_request, $request, $filesystem, '', 'php', dirname(__FILE__) . '/');
     $this->pagination = new \phpbb\pagination($this->template, $this->user, $this->helper, $phpbb_dispatcher);
 }
 /**
  * Gets the 'controller.provider' service.
  *
  * This service is shared.
  * This method always returns the same instance of the service.
  *
  * @return \phpbb\controller\provider A phpbb\controller\provider instance.
  */
 protected function getController_ProviderService()
 {
     $this->services['controller.provider'] = $instance = new \phpbb\controller\provider();
     $instance->find('./');
     return $instance;
 }