1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/* |
4
|
|
|
* This file is part of the CMS Kernel package. |
5
|
|
|
* |
6
|
|
|
* Copyright (c) 2016-present LIN3S <[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
|
|
|
namespace LIN3S\CMSKernel\Infrastructure\BenGorFileBundle\DependencyInjection\Compiler; |
13
|
|
|
|
14
|
|
|
use LIN3S\CMSKernel\Infrastructure\BenGorFileBundle\HttpAction\AjaxFileGalleryAction; |
15
|
|
|
use LIN3S\CMSKernel\Infrastructure\BenGorFileBundle\HttpAction\AjaxFileUploadAction; |
16
|
|
|
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; |
17
|
|
|
use Symfony\Component\DependencyInjection\ContainerBuilder; |
18
|
|
|
use Symfony\Component\DependencyInjection\Definition; |
19
|
|
|
|
20
|
|
|
/** |
21
|
|
|
* @author Beñat Espiña <[email protected]> |
22
|
|
|
*/ |
23
|
|
|
class DeclareHttpActionsPass implements CompilerPassInterface |
24
|
|
|
{ |
25
|
|
|
public function process(ContainerBuilder $container) |
26
|
|
|
{ |
27
|
|
|
$config = $container->getParameter('cms_kernel_bengor_file_bridge.config'); |
28
|
|
|
|
29
|
|
|
foreach ($config['file_types'] as $fileType => $fileTypeConfig) { |
30
|
|
|
$container->setDefinition( |
31
|
|
|
'cms_kernel_bengor_file.http_action.' . $fileType . '_upload', |
32
|
|
|
(new Definition( |
33
|
|
|
AjaxFileUploadAction::class, [ |
34
|
|
|
$container->getDefinition('bengor_file.' . $fileType . '.command_bus'), |
35
|
|
|
] |
36
|
|
|
)) |
37
|
|
|
); |
38
|
|
|
} |
39
|
|
|
|
40
|
|
|
foreach ($config['file_types'] as $fileType => $fileTypeConfig) { |
41
|
|
|
$container->setDefinition( |
42
|
|
|
'cms_kernel_bengor_file.http_action.' . $fileType . '_gallery', |
43
|
|
|
(new Definition( |
44
|
|
|
AjaxFileGalleryAction::class, [ |
45
|
|
|
$container->getDefinition('bengor.file.application.query.all_' . $fileType . 's'), |
46
|
|
|
] |
47
|
|
|
)) |
48
|
|
|
); |
49
|
|
|
} |
50
|
|
|
} |
51
|
|
|
} |
52
|
|
|
|