|
1
|
|
|
<?php |
|
2
|
|
|
/* |
|
3
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
|
4
|
|
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
|
5
|
|
|
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
|
6
|
|
|
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
|
7
|
|
|
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
|
8
|
|
|
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
|
9
|
|
|
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
|
10
|
|
|
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
|
11
|
|
|
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
|
12
|
|
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
|
13
|
|
|
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
|
14
|
|
|
* |
|
15
|
|
|
* This software consists of voluntary contributions made by many individuals |
|
16
|
|
|
* and is licensed under the MIT license. For more information, see |
|
17
|
|
|
* <http://www.doctrine-project.org>. |
|
18
|
|
|
*/ |
|
19
|
|
|
|
|
20
|
|
|
namespace Baleen\Migrations\Migration\Repository\Mapper; |
|
21
|
|
|
use Baleen\Migrations\Migration\MigrationInterface; |
|
22
|
|
|
use Baleen\Migrations\Common\ValueObjectInterface; |
|
23
|
|
|
use Baleen\Migrations\Delta\DeltaId; |
|
24
|
|
|
|
|
25
|
|
|
/** |
|
26
|
|
|
* Class Definition |
|
27
|
|
|
* |
|
28
|
|
|
* @author Gabriel Somoza <[email protected]> |
|
29
|
|
|
*/ |
|
30
|
|
|
final class Definition implements DefinitionInterface |
|
31
|
|
|
{ |
|
32
|
|
|
/** @var DeltaId */ |
|
33
|
|
|
private $id; |
|
34
|
|
|
|
|
35
|
|
|
/** @var MigrationInterface */ |
|
36
|
|
|
private $migration; |
|
37
|
|
|
|
|
38
|
|
|
/** |
|
39
|
|
|
* Definition constructor. |
|
40
|
|
|
* @param MigrationInterface $migration |
|
41
|
|
|
* @param null|string|ValueObjectInterface $id Overrides the ID for the migration with the specified ID |
|
42
|
|
|
*/ |
|
43
|
8 |
|
public function __construct(MigrationInterface $migration, $id = null) |
|
44
|
|
|
{ |
|
45
|
8 |
|
if (null === $id) { |
|
46
|
7 |
|
$id = DeltaId::fromMigration($migration); |
|
47
|
7 |
|
} else { |
|
48
|
1 |
|
$id = new DeltaId((string) $id); |
|
49
|
|
|
} |
|
50
|
8 |
|
$this->id = $id; |
|
51
|
|
|
|
|
52
|
8 |
|
$this->migration = $migration; |
|
53
|
8 |
|
} |
|
54
|
|
|
|
|
55
|
|
|
/** |
|
56
|
|
|
* @inheritdoc |
|
57
|
|
|
*/ |
|
58
|
3 |
|
public function getId() |
|
59
|
|
|
{ |
|
60
|
3 |
|
return $this->id; |
|
61
|
|
|
} |
|
62
|
|
|
|
|
63
|
|
|
/** |
|
64
|
|
|
* @return MigrationInterface |
|
65
|
|
|
*/ |
|
66
|
2 |
|
public function getMigration() |
|
67
|
|
|
{ |
|
68
|
2 |
|
return $this->migration; |
|
69
|
|
|
} |
|
70
|
|
|
} |
|
71
|
|
|
|