Exponential Basic 2.4.0.1 Exponential Basic CMS — PHP Class Reference

versioned_route.php
Go to the documentation of this file.
1 <?php
15 class ezpRestVersionedRoute implements ezcMvcRoute, ezcMvcReversibleRoute
16 {
20 protected $route;
21
25 protected $version;
26
27 public function __construct( ezcMvcRoute $route, $version )
28 {
29 $this->route = $route;
30 $this->version = (int)$version;
31 }
32
33 public function matches( ezcMvcRequest $request )
34 {
35 // IF we put versionToken back into route pattern, then the following is true
36 // new ezcMvcRailsRoute( '/api/:versionToken/foo', 'myController', 'myAction' ),
37 // the token is available at: $request->variables['versionToken']
38 // Which means, specifying it in the route pattern, allows us to reuse more of the current MvcTols code.
39 // But results in more code and configuration up-front for developers.
40 //
41 // In the case of ezpRestRequest, a specific getVersion() could also be implemented.
42 // /api/v1 + /foo ezpRestVersionedRailsRoute
43 // /api/v1/foo -> ezPrestVersionedRailsRoute /api/v1/foo -> /foo
44
45 // matches() ==> is this version string registered? if so call it, if not call the default, as if no version info is provided or fail?
46 switch ( ezpRestPrefixFilterInterface::getApiVersion() )
47 {
48 case $this->version:
49 return $this->route->matches( $request );
50 break;
51 }
52 }
53
60 public function prefix( $prefix )
61 {
62 $this->route->prefix( $prefix );
63 }
64
70 public function generateUrl( array $arguments = null )
71 {
72 // ezpRestPrefixFilterInterface::getScheme() ==> '/v'
73 $apiPrefix = ezpRestPrefixFilterInterface::getApiPrefix() . '/';
74 $apiProviderName = ezpRestPrefixFilterInterface::getApiProviderName();
75
76 return $apiPrefix . ( !$apiProviderName ? '' : $apiProviderName . '/' ) . 'v' . $this->version . '/' . str_replace( $apiPrefix, '', $this->route->generateUrl( $arguments ) );
77 }
78 }
ezpRestPrefixFilterInterface\getApiVersion
static getApiVersion()
Definition: prefix_filter.php:83
ezpRestPrefixFilterInterface\getApiProviderName
static getApiProviderName()
Definition: prefix_filter.php:98
ezpRestPrefixFilterInterface\getApiPrefix
static getApiPrefix()
Definition: prefix_filter.php:113
ezpRestVersionedRoute
Definition: versioned_route.php:16
ezpRestVersionedRoute\generateUrl
generateUrl(array $arguments=null)
Definition: versioned_route.php:70
ezpRestVersionedRoute\prefix
prefix( $prefix)
Definition: versioned_route.php:60
ezpRestVersionedRoute\matches
matches(ezcMvcRequest $request)
Definition: versioned_route.php:33
ezpRestVersionedRoute\$version
$version
Definition: versioned_route.php:25
ezpRestVersionedRoute\__construct
__construct(ezcMvcRoute $route, $version)
Definition: versioned_route.php:27
ezpRestVersionedRoute\$route
$route
Definition: versioned_route.php:20
version
version()
Definition: eztrade/xmlrpc/xmlrpcserver.php:70
Copyright © 1998 – 2026 7x. All rights reserved. Licensed under the GNU GPLv2+.