1 | <?php |
||
15 | abstract class BaseHandler implements ApiHandlerInterface |
||
16 | { |
||
17 | /** |
||
18 | * @var Manager|null |
||
19 | */ |
||
20 | private $fractal; |
||
21 | |||
22 | /** |
||
23 | * @var EndpointInterface|null |
||
24 | */ |
||
25 | private $endpoint; |
||
26 | |||
27 | /** |
||
28 | * @var LinkGenerator|null |
||
29 | */ |
||
30 | protected $linkGenerator; |
||
31 | |||
32 | 63 | public function __construct(ScopeFactoryInterface $scopeFactory = null) |
|
36 | |||
37 | /** |
||
38 | * {@inheritdoc} |
||
39 | */ |
||
40 | 3 | public function summary(): string |
|
44 | |||
45 | /** |
||
46 | * {@inheritdoc} |
||
47 | */ |
||
48 | 3 | public function description(): string |
|
52 | |||
53 | /** |
||
54 | * {@inheritdoc} |
||
55 | */ |
||
56 | 9 | public function params(): array |
|
60 | |||
61 | /** |
||
62 | * {@inheritdoc} |
||
63 | */ |
||
64 | 3 | public function tags(): array |
|
68 | |||
69 | /** |
||
70 | * {@inheritdoc} |
||
71 | */ |
||
72 | 3 | public function deprecated(): bool |
|
76 | |||
77 | /** |
||
78 | * {@inheritdoc} |
||
79 | */ |
||
80 | 3 | public function outputs(): array |
|
84 | |||
85 | 3 | protected function getFractal(): Manager |
|
92 | |||
93 | /** |
||
94 | * {@inheritdoc} |
||
95 | */ |
||
96 | 33 | final public function setEndpointIdentifier(EndpointInterface $endpoint): void |
|
100 | |||
101 | 12 | final public function getEndpoint(): ?EndpointInterface |
|
105 | |||
106 | /** |
||
107 | * Set link generator to handler |
||
108 | * |
||
109 | * @param LinkGenerator $linkGenerator |
||
110 | * |
||
111 | * @return self |
||
112 | */ |
||
113 | 12 | final public function setupLinkGenerator(LinkGenerator $linkGenerator): self |
|
118 | |||
119 | /** |
||
120 | * Create link to actual handler endpoint |
||
121 | * |
||
122 | * @param array $params |
||
123 | * |
||
124 | * @return string |
||
125 | * @throws InvalidLinkException if handler doesn't have linkgenerator or endpoint |
||
126 | */ |
||
127 | 18 | final public function createLink(array $params = []): string |
|
142 | |||
143 | /** |
||
144 | * {@inheritdoc} |
||
145 | */ |
||
146 | abstract public function handle(array $params): ResponseInterface; |
||
147 | } |
||
148 |