|
29 | 29 | */
|
30 | 30 | final class ApiDocumentationBuilder implements ApiDocumentationBuilderInterface
|
31 | 31 | {
|
32 |
| - /** |
33 |
| - * @var ResourceNameCollectionFactoryInterface |
34 |
| - */ |
35 | 32 | private $resourceNameCollectionFactory;
|
36 |
| - |
37 |
| - /** |
38 |
| - * @var ResourceMetadataFactoryInterface |
39 |
| - */ |
40 | 33 | private $resourceMetadataFactory;
|
41 |
| - |
42 |
| - /** |
43 |
| - * @var PropertyNameCollectionFactoryInterface |
44 |
| - */ |
45 | 34 | private $propertyNameCollectionFactory;
|
46 |
| - |
47 |
| - /** |
48 |
| - * @var PropertyMetadataFactoryInterface |
49 |
| - */ |
50 | 35 | private $propertyMetadataFactory;
|
51 |
| - |
52 |
| - /** |
53 |
| - * @var ContextBuilderInterface |
54 |
| - */ |
55 | 36 | private $contextBuilder;
|
56 |
| - |
57 |
| - /** |
58 |
| - * @var ResourceClassResolverInterface |
59 |
| - */ |
60 | 37 | private $resourceClassResolver;
|
61 |
| - |
62 |
| - /** |
63 |
| - * @var OperationMethodResolverInterface |
64 |
| - */ |
65 | 38 | private $operationMethodResolver;
|
66 |
| - |
67 |
| - /** |
68 |
| - * @var UrlGeneratorInterface |
69 |
| - */ |
70 | 39 | private $urlGenerator;
|
71 |
| - |
72 |
| - /** |
73 |
| - * @var string |
74 |
| - */ |
75 | 40 | private $title;
|
76 |
| - |
77 |
| - /** |
78 |
| - * @var string |
79 |
| - */ |
80 | 41 | private $description;
|
81 | 42 |
|
82 |
| - public function __construct(ResourceNameCollectionFactoryInterface $resourceNameCollectionFactory, ResourceMetadataFactoryInterface $resourceMetadataFactory, PropertyNameCollectionFactoryInterface $propertyNameCollectionFactory, PropertyMetadataFactoryInterface $propertyMetadataFactory, ContextBuilderInterface $contextBuilder, ResourceClassResolverInterface $resourceClassResolver, OperationMethodResolverInterface $operationMethodResolver, UrlGeneratorInterface $urlGenerator, string $title, string $description) |
| 43 | + public function __construct(ResourceNameCollectionFactoryInterface $resourceNameCollectionFactory, ResourceMetadataFactoryInterface $resourceMetadataFactory, PropertyNameCollectionFactoryInterface $propertyNameCollectionFactory, PropertyMetadataFactoryInterface $propertyMetadataFactory, ContextBuilderInterface $contextBuilder, ResourceClassResolverInterface $resourceClassResolver, OperationMethodResolverInterface $operationMethodResolver, UrlGeneratorInterface $urlGenerator, string $title = '', string $description = '') |
83 | 44 | {
|
84 | 45 | $this->resourceNameCollectionFactory = $resourceNameCollectionFactory;
|
85 | 46 | $this->resourceMetadataFactory = $resourceMetadataFactory;
|
@@ -275,14 +236,20 @@ public function getApiDocumentation()
|
275 | 236 | ],
|
276 | 237 | ];
|
277 | 238 |
|
278 |
| - return [ |
279 |
| - '@context' => $this->getContext(), |
280 |
| - '@id' => $this->urlGenerator->generate('api_hydra_vocab'), |
281 |
| - 'hydra:title' => $this->title, |
282 |
| - 'hydra:description' => $this->description, |
283 |
| - 'hydra:entrypoint' => $this->urlGenerator->generate('api_jsonld_entrypoint'), |
284 |
| - 'hydra:supportedClass' => $classes, |
285 |
| - ]; |
| 239 | + $doc = ['@context' => $this->getContext(), '@id' => $this->urlGenerator->generate('api_hydra_vocab')]; |
| 240 | + |
| 241 | + if ('' !== $this->title) { |
| 242 | + $doc['hydra:title'] = $this->title; |
| 243 | + } |
| 244 | + |
| 245 | + if ('' !== $this->description) { |
| 246 | + $doc['hydra:description'] = $this->description; |
| 247 | + } |
| 248 | + |
| 249 | + $doc['hydra:entrypoint'] = $this->urlGenerator->generate('api_jsonld_entrypoint'); |
| 250 | + $doc['hydra:supportedClass'] = $classes; |
| 251 | + |
| 252 | + return $doc; |
286 | 253 | }
|
287 | 254 |
|
288 | 255 | /**
|
|
0 commit comments