1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/* |
4
|
|
|
* This file is part of the Silverback API Components Bundle Project |
5
|
|
|
* |
6
|
|
|
* (c) Daniel West <[email protected]> |
7
|
|
|
* |
8
|
|
|
* For the full copyright and license information, please view the LICENSE |
9
|
|
|
* file that was distributed with this source code. |
10
|
|
|
*/ |
11
|
|
|
|
12
|
|
|
declare(strict_types=1); |
13
|
|
|
|
14
|
|
|
namespace Silverback\ApiComponentsBundle\OpenApi; |
15
|
|
|
|
16
|
|
|
use ApiPlatform\Core\OpenApi\Factory\OpenApiFactoryInterface; |
17
|
|
|
use ApiPlatform\Core\OpenApi\OpenApi; |
18
|
|
|
use PackageVersions\Versions; |
19
|
|
|
use Silverback\ApiComponentsBundle\Entity\Component\Form; |
20
|
|
|
use Silverback\ApiComponentsBundle\Entity\Core\AbstractComponent; |
21
|
|
|
|
22
|
|
|
/** |
23
|
|
|
* @author Daniel West <[email protected]> |
24
|
|
|
*/ |
25
|
|
|
class OpenApiFactory implements OpenApiFactoryInterface |
26
|
|
|
{ |
27
|
|
|
private $decorated; |
28
|
|
|
|
29
|
|
|
public function __construct(OpenApiFactoryInterface $decorated) |
30
|
|
|
{ |
31
|
|
|
$this->decorated = $decorated; |
32
|
|
|
} |
33
|
|
|
|
34
|
|
|
public function __invoke(array $context = []): OpenApi |
35
|
|
|
{ |
36
|
|
|
$openApi = $this->decorated->__invoke($context); |
37
|
|
|
$version = sprintf('%s (%s)', $openApi->getInfo()->getVersion(), Versions::getVersion('silverbackis/api-components-bundle')); |
38
|
|
|
|
39
|
|
|
return $openApi->withInfo($openApi->getInfo()->withVersion($version)); |
40
|
|
|
// $components = $openApi->getComponents(); |
41
|
|
|
// $classes = []; |
42
|
|
|
// $unsupported = [Form::class, AbstractComponent::class]; |
43
|
|
|
// foreach ($components as $className => $component) { |
44
|
|
|
// if (\in_array($className, $unsupported, true)) { |
45
|
|
|
// continue; |
46
|
|
|
// } |
47
|
|
|
// $classes[] = $className; |
48
|
|
|
// } |
49
|
|
|
// $newResourceNameCollection = new ResourceNameCollection($classes); |
50
|
|
|
} |
51
|
|
|
} |
52
|
|
|
|