PluginProbe
Packeta / 1.5.3
Packeta v1.5.3
2.3.2 2.3.1 trunk 1.2.2 1.2.3 1.2.4 1.2.5 1.2.6 1.3.0 1.3.1 1.3.2 1.4 1.4.1 1.4.2 1.4.3 1.5.0 1.5.1 1.5.2 1.5.3 1.5.4 1.6.0 1.6.1 1.6.2 1.6.3 1.6.4 All 56 releases
packeta / src / Packetery / Module / Order / ControllerRouter.php

ControllerRouter.php in Packeta 1.5.3, at src/Packetery/Module/Order/ControllerRouter.php

79 lines 1.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Class ControllerRouter
4 *
5 * @package Packetery\Module\Order
6 */
7
8 declare( strict_types=1 );
9
10
11 namespace Packetery\Module\Order;
12
13 /**
14 * Class ControllerRouter
15 *
16 * @package Packetery\Module\Order
17 */
18 class ControllerRouter {
19 /**
20 * Namespace.
21 *
22 * @var string
23 */
24 private $namespace = 'packetery/v1';
25
26 /**
27 * Rest base,
28 *
29 * @var string
30 */
31 private $restBase = 'order';
32
33 /**
34 * Gets namespace.
35 *
36 * @return string
37 */
38 public function getNamespace(): string {
39 return $this->namespace;
40 }
41
42 /**
43 * Gets rest base.
44 *
45 * @return string
46 */
47 public function getRestBase(): string {
48 return $this->restBase;
49 }
50
51 /**
52 * Gets route URL.
53 *
54 * @param string $path Short relative URL path.
55 */
56 public function getRouteUrl( string $path ): string {
57 return get_rest_url( null, $this->namespace . $this->getRoute( $path ) );
58 }
59
60 /**
61 * Gets route.
62 *
63 * @param string $path Short relative URL path.
64 */
65 public function getRoute( string $path ): string {
66 return "/{$this->restBase}{$path}";
67 }
68
69 /**
70 * Register route.
71 *
72 * @param string $path Short relative URL path.
73 * @param array $params Route configuration.
74 */
75 public function registerRoute( string $path, array $params ): void {
76 register_rest_route( $this->namespace, $this->getRoute( $path ), $params );
77 }
78 }
79