| @@ 26-71 (lines=46) @@ | ||
| 23 | * |
|
| 24 | * @author Bernhard Schussek <[email protected]> |
|
| 25 | */ |
|
| 26 | class RemoveBindingDescriptorFromModuleFile implements AtomicOperation |
|
| 27 | { |
|
| 28 | /** |
|
| 29 | * @var Uuid |
|
| 30 | */ |
|
| 31 | private $uuid; |
|
| 32 | ||
| 33 | /** |
|
| 34 | * @var RootModuleFile |
|
| 35 | */ |
|
| 36 | private $rootModuleFile; |
|
| 37 | ||
| 38 | /** |
|
| 39 | * @var BindingDescriptor |
|
| 40 | */ |
|
| 41 | private $previousDescriptor; |
|
| 42 | ||
| 43 | public function __construct(Uuid $uuid, RootModuleFile $rootModuleFile) |
|
| 44 | { |
|
| 45 | $this->uuid = $uuid; |
|
| 46 | $this->rootModuleFile = $rootModuleFile; |
|
| 47 | } |
|
| 48 | ||
| 49 | /** |
|
| 50 | * {@inheritdoc} |
|
| 51 | */ |
|
| 52 | public function execute() |
|
| 53 | { |
|
| 54 | if (!$this->rootModuleFile->hasBindingDescriptor($this->uuid)) { |
|
| 55 | return; |
|
| 56 | } |
|
| 57 | ||
| 58 | $this->previousDescriptor = $this->rootModuleFile->getBindingDescriptor($this->uuid); |
|
| 59 | $this->rootModuleFile->removeBindingDescriptor($this->uuid); |
|
| 60 | } |
|
| 61 | ||
| 62 | /** |
|
| 63 | * {@inheritdoc} |
|
| 64 | */ |
|
| 65 | public function rollback() |
|
| 66 | { |
|
| 67 | if ($this->previousDescriptor) { |
|
| 68 | $this->rootModuleFile->addBindingDescriptor($this->previousDescriptor); |
|
| 69 | } |
|
| 70 | } |
|
| 71 | } |
|
| 72 | ||
| @@ 25-70 (lines=46) @@ | ||
| 22 | * |
|
| 23 | * @author Bernhard Schussek <[email protected]> |
|
| 24 | */ |
|
| 25 | class RemoveTypeDescriptorFromModuleFile implements AtomicOperation |
|
| 26 | { |
|
| 27 | /** |
|
| 28 | * @var BindingTypeDescriptor |
|
| 29 | */ |
|
| 30 | private $typeName; |
|
| 31 | ||
| 32 | /** |
|
| 33 | * @var RootModuleFile |
|
| 34 | */ |
|
| 35 | private $rootModuleFile; |
|
| 36 | ||
| 37 | /** |
|
| 38 | * @var BindingTypeDescriptor |
|
| 39 | */ |
|
| 40 | private $previousDescriptor; |
|
| 41 | ||
| 42 | public function __construct($typeName, RootModuleFile $rootModuleFile) |
|
| 43 | { |
|
| 44 | $this->typeName = $typeName; |
|
| 45 | $this->rootModuleFile = $rootModuleFile; |
|
| 46 | } |
|
| 47 | ||
| 48 | /** |
|
| 49 | * {@inheritdoc} |
|
| 50 | */ |
|
| 51 | public function execute() |
|
| 52 | { |
|
| 53 | if (!$this->rootModuleFile->hasTypeDescriptor($this->typeName)) { |
|
| 54 | return; |
|
| 55 | } |
|
| 56 | ||
| 57 | $this->previousDescriptor = $this->rootModuleFile->getTypeDescriptor($this->typeName); |
|
| 58 | $this->rootModuleFile->removeTypeDescriptor($this->typeName); |
|
| 59 | } |
|
| 60 | ||
| 61 | /** |
|
| 62 | * {@inheritdoc} |
|
| 63 | */ |
|
| 64 | public function rollback() |
|
| 65 | { |
|
| 66 | if ($this->previousDescriptor) { |
|
| 67 | $this->rootModuleFile->addTypeDescriptor($this->previousDescriptor); |
|
| 68 | } |
|
| 69 | } |
|
| 70 | } |
|
| 71 | ||