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\Remove\RemoveFileCommand; |
16
|
|
|
use BenGorFile\File\Application\Command\Remove\RemoveFileHandler; |
17
|
|
|
use Symfony\Component\DependencyInjection\Definition; |
18
|
|
|
|
19
|
|
|
/** |
20
|
|
|
* Remove file command builder. |
21
|
|
|
* |
22
|
|
|
* @author Beñat Espiña <[email protected]> |
23
|
|
|
*/ |
24
|
|
View Code Duplication |
class RemoveFileCommandBuilder 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
|
|
|
RemoveFileHandler::class, [ |
35
|
|
|
$this->container->getDefinition( |
36
|
|
|
'bengor.file.infrastructure.domain.model.' . $file . '_filesystem' |
37
|
|
|
), |
38
|
|
|
$this->container->getDefinition( |
39
|
|
|
'bengor.file.infrastructure.persistence.' . $file . '_repository' |
40
|
|
|
), |
41
|
|
|
] |
42
|
|
|
))->addTag( |
43
|
|
|
'bengor_file_' . $file . '_command_bus_handler', [ |
44
|
|
|
'handles' => RemoveFileCommand::class, |
45
|
|
|
] |
46
|
|
|
) |
47
|
|
|
); |
48
|
|
|
} |
49
|
|
|
|
50
|
|
|
/** |
51
|
|
|
* {@inheritdoc} |
52
|
|
|
*/ |
53
|
|
|
protected function definitionName($file) |
54
|
|
|
{ |
55
|
|
|
return 'bengor.file.application.command.remove_' . $file; |
56
|
|
|
} |
57
|
|
|
|
58
|
|
|
/** |
59
|
|
|
* {@inheritdoc} |
60
|
|
|
*/ |
61
|
|
|
protected function aliasDefinitionName($file) |
62
|
|
|
{ |
63
|
|
|
return 'bengor_file.' . $file . '.remove'; |
64
|
|
|
} |
65
|
|
|
} |
66
|
|
|
|
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.