1
|
|
|
<?php |
2
|
|
|
namespace LunixREST\Server\Router\EndpointFactory; |
3
|
|
|
|
4
|
|
|
use LunixREST\Server\Router\Endpoint\CachingEndpoint; |
5
|
|
|
use LunixREST\Server\Router\Endpoint\LoggingEndpoint; |
6
|
|
|
use LunixREST\Server\Router\EndpointFactory\Exceptions\UnableToCreateEndpointException; |
7
|
|
|
use Psr\Cache\CacheItemPoolInterface; |
8
|
|
|
use Psr\Log\LoggerInterface; |
9
|
|
|
|
10
|
|
|
/** |
11
|
|
|
* An EndpointFactory that extends LoggingEndpointFactory, using a CachingEndpoint by setting a CachePoolInterface on the Endpoint. |
12
|
|
|
* Class CachingEndpointFactory |
13
|
|
|
* @package LunixREST\Server\Router\EndpointFactory |
14
|
|
|
* @deprecated in favor of injecting the CacheItemPoolInterface manually in EndpointFactories. This adds no additional value. |
15
|
|
|
*/ |
16
|
|
|
abstract class CachingEndpointFactory extends LoggingEndpointFactory |
|
|
|
|
17
|
|
|
{ |
18
|
|
|
/** |
19
|
|
|
* @var CacheItemPoolInterface |
20
|
|
|
*/ |
21
|
|
|
protected $cachePool; |
22
|
|
|
|
23
|
|
|
/** |
24
|
|
|
* CachingEndpointFactory constructor. |
25
|
|
|
* @param CacheItemPoolInterface $cachePool |
26
|
|
|
* @param LoggerInterface $logger |
27
|
|
|
*/ |
28
|
1 |
|
public function __construct(CacheItemPoolInterface $cachePool, LoggerInterface $logger) |
29
|
|
|
{ |
30
|
1 |
|
$this->cachePool = $cachePool; |
31
|
1 |
|
parent::__construct($logger); |
32
|
1 |
|
} |
33
|
|
|
|
34
|
|
|
/** |
35
|
|
|
* @param string $name |
36
|
|
|
* @param string $version |
37
|
|
|
* @return LoggingEndpoint |
38
|
|
|
* @throws UnableToCreateEndpointException |
39
|
|
|
*/ |
40
|
1 |
|
protected function getLoggingEndpoint(string $name, string $version): LoggingEndpoint |
41
|
|
|
{ |
42
|
1 |
|
$endpoint = $this->getCachingEndpoint($name, $version); |
43
|
1 |
|
$endpoint->setCachePool($this->cachePool); |
44
|
1 |
|
return $endpoint; |
45
|
|
|
} |
46
|
|
|
|
47
|
|
|
/** |
48
|
|
|
* @param string $name |
49
|
|
|
* @param string $version |
50
|
|
|
* @return CachingEndpoint |
51
|
|
|
* @throws UnableToCreateEndpointException |
52
|
|
|
*/ |
53
|
|
|
protected abstract function getCachingEndpoint(string $name, string $version): CachingEndpoint; |
|
|
|
|
54
|
|
|
} |
55
|
|
|
|
This class, trait or interface has been deprecated. The supplier of the file has supplied an explanatory message.
The explanatory message should give you some clue as to whether and when the type will be removed from the class and what other constant to use instead.