PageRenderTime 42ms CodeModel.GetById 9ms RepoModel.GetById 0ms app.codeStats 0ms

/tests/Symfony/Tests/Component/Routing/Fixtures/dumper/url_matcher1.php

http://github.com/fabpot/symfony
PHP | 93 lines | 62 code | 13 blank | 18 comment | 19 complexity | 03e43a071f81c1cf9178376b0dba1371 MD5 | raw file
  1. <?php
  2. use Symfony\Component\Routing\Matcher\Exception\MethodNotAllowedException;
  3. use Symfony\Component\Routing\Matcher\Exception\NotFoundException;
  4. use Symfony\Component\Routing\RequestContext;
  5. /**
  6. * ProjectUrlMatcher
  7. *
  8. * This class has been auto-generated
  9. * by the Symfony Routing Component.
  10. */
  11. class ProjectUrlMatcher extends Symfony\Component\Routing\Matcher\UrlMatcher
  12. {
  13. /**
  14. * Constructor.
  15. */
  16. public function __construct(RequestContext $context)
  17. {
  18. $this->context = $context;
  19. }
  20. public function match($pathinfo)
  21. {
  22. $allow = array();
  23. // foo
  24. if (0 === strpos($pathinfo, '/foo') && preg_match('#^/foo/(?P<bar>baz|symfony)$#x', $pathinfo, $matches)) {
  25. return array_merge($this->mergeDefaults($matches, array ( 'def' => 'test',)), array('_route' => 'foo'));
  26. }
  27. // bar
  28. if (0 === strpos($pathinfo, '/bar') && preg_match('#^/bar/(?P<foo>[^/]+?)$#x', $pathinfo, $matches)) {
  29. if (!in_array($this->context->getMethod(), array('get', 'head'))) {
  30. $allow = array_merge($allow, array('get', 'head'));
  31. goto not_bar;
  32. }
  33. $matches['_route'] = 'bar';
  34. return $matches;
  35. }
  36. not_bar:
  37. // baz
  38. if ($pathinfo === '/test/baz') {
  39. return array('_route' => 'baz');
  40. }
  41. // baz2
  42. if ($pathinfo === '/test/baz.html') {
  43. return array('_route' => 'baz2');
  44. }
  45. // baz3
  46. if ($pathinfo === '/test/baz3/') {
  47. return array('_route' => 'baz3');
  48. }
  49. // baz4
  50. if (0 === strpos($pathinfo, '/test') && preg_match('#^/test/(?P<foo>[^/]+?)/$#x', $pathinfo, $matches)) {
  51. $matches['_route'] = 'baz4';
  52. return $matches;
  53. }
  54. // baz5
  55. if (0 === strpos($pathinfo, '/test') && preg_match('#^/test/(?P<foo>[^/]+?)/$#x', $pathinfo, $matches)) {
  56. if ($this->context->getMethod() != 'post') {
  57. $allow[] = 'post';
  58. goto not_baz5;
  59. }
  60. $matches['_route'] = 'baz5';
  61. return $matches;
  62. }
  63. not_baz5:
  64. // baz.baz6
  65. if (0 === strpos($pathinfo, '/test') && preg_match('#^/test/(?P<foo>[^/]+?)/$#x', $pathinfo, $matches)) {
  66. if ($this->context->getMethod() != 'put') {
  67. $allow[] = 'put';
  68. goto not_bazbaz6;
  69. }
  70. $matches['_route'] = 'baz.baz6';
  71. return $matches;
  72. }
  73. not_bazbaz6:
  74. // foofoo
  75. if ($pathinfo === '/foofoo') {
  76. return array ( 'def' => 'test', '_route' => 'foofoo',);
  77. }
  78. throw 0 < count($allow) ? new MethodNotAllowedException(array_unique($allow)) : new NotFoundException();
  79. }
  80. }