1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/* |
4
|
|
|
* This file is part of the BenGorFile package. |
5
|
|
|
* |
6
|
|
|
* (c) Beñat Espiña <[email protected]> |
7
|
|
|
* (c) Gorka Laucirica <[email protected]> |
8
|
|
|
* |
9
|
|
|
* For the full copyright and license information, please view the LICENSE |
10
|
|
|
* file that was distributed with this source code. |
11
|
|
|
*/ |
12
|
|
|
|
13
|
|
|
namespace BenGorFile\FileBundle\DependencyInjection\Compiler\Application\Command; |
14
|
|
|
|
15
|
|
|
use BenGorFile\File\Application\Command\Upload\UploadFileCommand; |
16
|
|
|
use BenGorFile\File\Application\Command\Upload\UploadFileHandler; |
17
|
|
|
use Symfony\Component\DependencyInjection\Definition; |
18
|
|
|
|
19
|
|
|
/** |
20
|
|
|
* Upload file command builder. |
21
|
|
|
* |
22
|
|
|
* @author Beñat Espiña <[email protected]> |
23
|
|
|
*/ |
24
|
|
|
class UploadFileCommandBuilder extends CommandBuilder |
25
|
|
|
{ |
26
|
|
|
/** |
27
|
|
|
* {@inheritdoc} |
28
|
|
|
*/ |
29
|
|
|
public function register($file) |
30
|
|
|
{ |
31
|
|
|
$this->container->setDefinition( |
32
|
|
|
$this->definitionName($file), |
33
|
|
|
(new Definition( |
34
|
|
|
UploadFileHandler::class, [ |
35
|
|
|
$this->container->getDefinition( |
36
|
|
|
'bengor.file.infrastructure.domain.model.gaufrette_filesystem_' . $file |
37
|
|
|
), |
38
|
|
|
$this->container->getDefinition( |
39
|
|
|
'bengor.file.infrastructure.persistence.' . $file . '_repository' |
40
|
|
|
), |
41
|
|
|
$this->container->getDefinition( |
42
|
|
|
'bengor.file.infrastructure.domain.model.' . $file . '_factory' |
43
|
|
|
), |
44
|
|
|
] |
45
|
|
|
))->addTag( |
46
|
|
|
'bengor_file_' . $file . '_command_bus_handler', [ |
47
|
|
|
'handles' => UploadFileCommand::class, |
48
|
|
|
] |
49
|
|
|
) |
50
|
|
|
); |
51
|
|
|
} |
52
|
|
|
|
53
|
|
|
/** |
54
|
|
|
* {@inheritdoc} |
55
|
|
|
*/ |
56
|
|
|
protected function definitionName($file) |
57
|
|
|
{ |
58
|
|
|
return 'bengor.file.application.command.upload_' . $file; |
59
|
|
|
} |
60
|
|
|
|
61
|
|
|
/** |
62
|
|
|
* {@inheritdoc} |
63
|
|
|
*/ |
64
|
|
|
protected function aliasDefinitionName($file) |
65
|
|
|
{ |
66
|
|
|
return 'bengor_file.' . $file . '.upload'; |
67
|
|
|
} |
68
|
|
|
} |
69
|
|
|
|