1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* TechDivision\Import\Cli\Configuration\Operation |
5
|
|
|
* |
6
|
|
|
* NOTICE OF LICENSE |
7
|
|
|
* |
8
|
|
|
* This source file is subject to the Open Software License (OSL 3.0) |
9
|
|
|
* that is available through the world-wide-web at this URL: |
10
|
|
|
* http://opensource.org/licenses/osl-3.0.php |
11
|
|
|
* |
12
|
|
|
* PHP version 5 |
13
|
|
|
* |
14
|
|
|
* @author Tim Wagner <[email protected]> |
15
|
|
|
* @copyright 2016 TechDivision GmbH <[email protected]> |
16
|
|
|
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) |
17
|
|
|
* @link https://github.com/techdivision/import-cli-simple |
18
|
|
|
* @link http://www.techdivision.com |
19
|
|
|
*/ |
20
|
|
|
|
21
|
|
|
namespace TechDivision\Import\Cli\Configuration; |
22
|
|
|
|
23
|
|
|
use JMS\Serializer\Annotation\Type; |
24
|
|
|
use TechDivision\Import\Configuration\OperationConfigurationInterface; |
25
|
|
|
|
26
|
|
|
/** |
27
|
|
|
* The configuration implementation for the options. |
28
|
|
|
* |
29
|
|
|
* @author Tim Wagner <[email protected]> |
30
|
|
|
* @copyright 2016 TechDivision GmbH <[email protected]> |
31
|
|
|
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) |
32
|
|
|
* @link https://github.com/techdivision/import-cli-simple |
33
|
|
|
* @link http://www.techdivision.com |
34
|
|
|
*/ |
35
|
|
|
class Operation implements OperationConfigurationInterface |
36
|
|
|
{ |
37
|
|
|
|
38
|
|
|
/** |
39
|
|
|
* The operation's name. |
40
|
|
|
* |
41
|
|
|
* @var string |
42
|
|
|
* @Type("string") |
43
|
|
|
*/ |
44
|
|
|
protected $name; |
45
|
|
|
|
46
|
|
|
/** |
47
|
|
|
* ArrayCollection with the information of the configured plugins. |
48
|
|
|
* |
49
|
|
|
* @var \Doctrine\Common\Collections\ArrayCollection |
50
|
|
|
* @Type("ArrayCollection<TechDivision\Import\Cli\Configuration\Plugin>") |
51
|
|
|
*/ |
52
|
|
|
protected $plugins; |
53
|
|
|
|
54
|
|
|
/** |
55
|
|
|
* Initialize the operation with the passed name. |
56
|
|
|
* |
57
|
|
|
* @param string|null $name The operation name |
58
|
|
|
*/ |
59
|
|
|
public function __construct($name = null) |
60
|
|
|
{ |
61
|
|
|
if ($name != null) { |
|
|
|
|
62
|
|
|
$this->name = $name; |
63
|
|
|
} |
64
|
|
|
} |
65
|
|
|
|
66
|
|
|
/** |
67
|
|
|
* Query's whether or not the passed operation equals this instance. |
68
|
|
|
* |
69
|
|
|
* @param \TechDivision\Import\Configuration\OperationConfigurationInterface $operation The operation to query |
70
|
|
|
* |
71
|
|
|
* @return boolean TRUE if the operations are equal, else FALSE |
72
|
|
|
*/ |
73
|
|
|
public function equals(OperationConfigurationInterface $operation) |
74
|
|
|
{ |
75
|
|
|
return strcasecmp($this->getName(), $operation->getName()) === 0; |
|
|
|
|
76
|
|
|
} |
77
|
|
|
|
78
|
|
|
/** |
79
|
|
|
* Return's the operation's name. |
80
|
|
|
* |
81
|
|
|
* @return string The operation's class name |
82
|
|
|
*/ |
83
|
|
|
public function getName() |
84
|
|
|
{ |
85
|
|
|
return $this->name; |
86
|
|
|
} |
87
|
|
|
|
88
|
|
|
/** |
89
|
|
|
* Return's the ArrayCollection with the operation's plugins. |
90
|
|
|
* |
91
|
|
|
* @return \Doctrine\Common\Collections\ArrayCollection The ArrayCollection with the operation's plugins |
92
|
|
|
*/ |
93
|
|
|
public function getPlugins() |
94
|
|
|
{ |
95
|
|
|
return $this->plugins; |
96
|
|
|
} |
97
|
|
|
|
98
|
|
|
/** |
99
|
|
|
* String representation of the operation (the name). |
100
|
|
|
* |
101
|
|
|
* @return string The operation name |
102
|
|
|
*/ |
103
|
|
|
public function __toString() |
104
|
|
|
{ |
105
|
|
|
return $this->getName(); |
|
|
|
|
106
|
|
|
} |
107
|
|
|
} |
108
|
|
|
|