1 | <?php |
||
13 | abstract class BaseHandler implements ApiHandlerInterface |
||
14 | { |
||
15 | /** |
||
16 | * @var Manager|null |
||
17 | */ |
||
18 | private $fractal; |
||
19 | |||
20 | /** |
||
21 | * @var EndpointInterface|null |
||
22 | */ |
||
23 | private $endpoint; |
||
24 | |||
25 | /** |
||
26 | * @var LinkGenerator|null |
||
27 | */ |
||
28 | protected $linkGenerator; |
||
29 | |||
30 | 63 | public function __construct(ScopeFactoryInterface $scopeFactory = null) |
|
34 | |||
35 | /** |
||
36 | * {@inheritdoc} |
||
37 | */ |
||
38 | 3 | public function summary(): string |
|
42 | |||
43 | /** |
||
44 | * {@inheritdoc} |
||
45 | */ |
||
46 | 3 | public function description(): string |
|
50 | |||
51 | /** |
||
52 | * {@inheritdoc} |
||
53 | */ |
||
54 | 9 | public function params(): array |
|
58 | |||
59 | /** |
||
60 | * {@inheritdoc} |
||
61 | */ |
||
62 | 3 | public function tags(): array |
|
66 | |||
67 | /** |
||
68 | * {@inheritdoc} |
||
69 | */ |
||
70 | 3 | public function deprecated(): bool |
|
74 | |||
75 | 3 | protected function getFractal(): Manager |
|
82 | |||
83 | /** |
||
84 | * {@inheritdoc} |
||
85 | */ |
||
86 | 30 | final public function setEndpointIdentifier(EndpointInterface $endpoint): void |
|
90 | |||
91 | 12 | final public function getEndpoint(): ?EndpointInterface |
|
95 | |||
96 | /** |
||
97 | * Set link generator to handler |
||
98 | * |
||
99 | * @param LinkGenerator $linkGenerator |
||
100 | * |
||
101 | * @return self |
||
102 | */ |
||
103 | 12 | final public function setupLinkGenerator(LinkGenerator $linkGenerator): self |
|
108 | |||
109 | /** |
||
110 | * Create link to actual handler endpoint |
||
111 | * |
||
112 | * @param array $params |
||
113 | * |
||
114 | * @return string |
||
115 | * @throws InvalidLinkException if handler doesn't have linkgenerator or endpoint |
||
116 | */ |
||
117 | 18 | final public function createLink(array $params = []): string |
|
132 | |||
133 | /** |
||
134 | * {@inheritdoc} |
||
135 | */ |
||
136 | abstract public function handle(array $params): ResponseInterface; |
||
137 | } |
||
138 |