|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* This file is part of the PSR Http Framework. |
|
4
|
|
|
* |
|
5
|
|
|
* (c) Dan Smith <[email protected]> |
|
6
|
|
|
* |
|
7
|
|
|
* For the full copyright and license information, please view the LICENSE |
|
8
|
|
|
* file that was distributed with this source code. |
|
9
|
|
|
*/ |
|
10
|
|
|
namespace Ds\Router\Adaptor; |
|
11
|
|
|
|
|
12
|
|
|
use Ds\Router\Interfaces\AdaptorInterface; |
|
13
|
|
|
use Ds\Router\Interfaces\RouteCollectionInterface; |
|
14
|
|
|
use Ds\Router\Interfaces\SerializerInterface; |
|
15
|
|
|
|
|
16
|
|
|
/** |
|
17
|
|
|
* Class AbstractAdaptor |
|
18
|
|
|
* |
|
19
|
|
|
* @package Ds\Router\Adaptor |
|
20
|
|
|
* @author Dan Smith <[email protected]> |
|
21
|
|
|
* @license http://opensource.org/licenses/gpl-license.php GNU Public License |
|
22
|
|
|
* @link https://github.com/djsmithme/Router |
|
23
|
|
|
*/ |
|
24
|
|
|
abstract class AbstractAdaptor implements AdaptorInterface |
|
25
|
|
|
{ |
|
26
|
|
|
/** |
|
27
|
|
|
* @var SerializerInterface |
|
28
|
|
|
*/ |
|
29
|
|
|
public $serializer; |
|
30
|
|
|
/** |
|
31
|
|
|
* @var array |
|
32
|
|
|
*/ |
|
33
|
|
|
protected $options = []; |
|
34
|
|
|
|
|
35
|
|
|
/** |
|
36
|
|
|
* Adaptor constructor. |
|
37
|
|
|
* @param SerializerInterface $serializer |
|
38
|
|
|
*/ |
|
39
|
|
|
public function __construct(SerializerInterface $serializer) |
|
40
|
|
|
{ |
|
41
|
|
|
$this->serializer = $serializer; |
|
42
|
|
|
} |
|
43
|
|
|
|
|
44
|
|
|
|
|
45
|
|
|
/** |
|
46
|
|
|
* @inheritdoc |
|
47
|
|
|
*/ |
|
48
|
|
|
public function getOptions() |
|
49
|
|
|
{ |
|
50
|
|
|
return $this->options; |
|
51
|
|
|
} |
|
52
|
|
|
|
|
53
|
|
|
/** |
|
54
|
|
|
* @inheritdoc |
|
55
|
|
|
*/ |
|
56
|
|
|
public function getOption($key) |
|
57
|
|
|
{ |
|
58
|
|
|
if (isset($this->options[$key])) { |
|
59
|
|
|
return $this->options[$key]; |
|
60
|
|
|
} |
|
61
|
|
|
return null; |
|
62
|
|
|
} |
|
63
|
|
|
|
|
64
|
|
|
/** |
|
65
|
|
|
* @inheritdoc |
|
66
|
|
|
*/ |
|
67
|
|
|
public function withOptions(array $options = []) |
|
68
|
|
|
{ |
|
69
|
|
|
$this->options = $options; |
|
70
|
|
|
} |
|
71
|
|
|
|
|
72
|
|
|
/** |
|
73
|
|
|
* @inheritdoc |
|
74
|
|
|
*/ |
|
75
|
|
|
abstract public function match(RouteCollectionInterface $routes, $method, $requestTarget); |
|
76
|
|
|
|
|
77
|
|
|
/** |
|
78
|
|
|
* @inheritdoc |
|
79
|
|
|
*/ |
|
80
|
|
|
abstract public function getCachedRoutes($context = ''); |
|
81
|
|
|
|
|
82
|
|
|
/** |
|
83
|
|
|
* @inheritdoc |
|
84
|
|
|
*/ |
|
85
|
|
|
abstract public function isCached(); |
|
86
|
|
|
} |
|
87
|
|
|
|