Exponential Basic 2.4.0.1 Exponential Basic CMS — PHP Class Reference

regexp.php
Go to the documentation of this file.
1 <?php
16 class ezpMvcRegexpRoute extends ezcMvcRegexpRoute
17 {
23 protected $protocolActionMap = array();
24
51 public function __construct( $pattern, $controllerClassName, $protocolActionMap, array $defaultValues = array() )
52 {
53 if ( is_string( $protocolActionMap ) )
54 {
55 $protocolActionMap = array( 'http-get' => $protocolActionMap );
56 }
57 if ( !isset( $protocolActionMap['http-options'] ) )
58 {
59 $protocolActionMap['http-options'] = 'httpOptions';
60 }
61 $this->protocolActionMap = $protocolActionMap;
62 parent::__construct( $pattern, $controllerClassName, '', $defaultValues );
63 }
64
69 public function prefix( $prefix )
70 {
71 // Detect the Regexp delimiter
72 $patternDelim = $this->pattern[0];
73
74 // Add the Regexp delimiter to the prefix
75 $prefix = $patternDelim . $prefix . $patternDelim;
76 parent::prefix( $prefix );
77 }
78
79
91 public function matches( ezcMvcRequest $request )
92 {
93 if ( $this->pregMatch( $request, $matches ) )
94 {
95 foreach ( $matches as $key => $match )
96 {
97 if ( is_numeric( $key ) )
98 {
99 unset( $matches[$key] );
100 }
101 }
102 if ( !isset( $this->protocolActionMap[$request->protocol] ) )
103 {
104 throw new ezpRouteMethodNotAllowedException( $this->getSupportedHTTPMethods() );
105 }
106 $request->variables = array_merge( $this->defaultValues, $request->variables, $matches );
107 if ( $request->protocol === 'http-options' )
108 {
109 $request->variables['supported_http_methods'] = $this->getSupportedHTTPMethods();
110 }
111 return new ezcMvcRoutingInformation( $this->pattern, $this->controllerClassName, $this->protocolActionMap[$request->protocol] );
112 }
113 return null;
114 }
115
122 protected function getSupportedHTTPMethods()
123 {
124 $methods = array_keys( $this->protocolActionMap );
125 foreach ( $methods as &$method )
126 {
127 $method = strtoupper( str_replace( 'http-', '', $method ) );
128 }
129 return $methods;
130 }
131
132 }
133 ?>
ezpMvcRegexpRoute
Definition: regexp.php:17
ezpMvcRegexpRoute\matches
matches(ezcMvcRequest $request)
Definition: regexp.php:91
ezpMvcRegexpRoute\prefix
prefix( $prefix)
Definition: regexp.php:69
ezpMvcRegexpRoute\getSupportedHTTPMethods
getSupportedHTTPMethods()
Definition: regexp.php:122
ezpMvcRegexpRoute\__construct
__construct( $pattern, $controllerClassName, $protocolActionMap, array $defaultValues=array())
Definition: regexp.php:51
ezpMvcRegexpRoute\$protocolActionMap
$protocolActionMap
Definition: regexp.php:23
ezpRouteMethodNotAllowedException
Definition: route_method_not_allowed.php:13
Copyright © 1998 – 2026 7x. All rights reserved. Licensed under the GNU GPLv2+.