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 | public function additionalData(): array |
|
89 | |||
90 | protected function getFractal(): Manager |
||
97 | |||
98 | 33 | /** |
|
99 | 33 | * {@inheritdoc} |
|
100 | */ |
||
101 | 12 | final public function setEndpointIdentifier(EndpointInterface $endpoint): void |
|
105 | |||
106 | final public function getEndpoint(): ?EndpointInterface |
||
110 | |||
111 | /** |
||
112 | * Set link generator to handler |
||
113 | 12 | * |
|
114 | * @param LinkGenerator $linkGenerator |
||
115 | 12 | * |
|
116 | 12 | * @return self |
|
117 | */ |
||
118 | final public function setupLinkGenerator(LinkGenerator $linkGenerator): self |
||
123 | |||
124 | /** |
||
125 | * Create link to actual handler endpoint |
||
126 | * |
||
127 | 18 | * @param array $params |
|
128 | * |
||
129 | 18 | * @return string |
|
130 | 6 | * @throws InvalidLinkException if handler doesn't have linkgenerator or endpoint |
|
131 | */ |
||
132 | 12 | final public function createLink(array $params = []): string |
|
147 | |||
148 | /** |
||
149 | * {@inheritdoc} |
||
150 | */ |
||
151 | abstract public function handle(array $params): ResponseInterface; |
||
152 | } |
||
153 |