1 | <?php |
||
2 | |||
3 | namespace Kaliop\eZMigrationBundle\API\Value; |
||
4 | |||
5 | use Kaliop\eZMigrationBundle\API\Collection\MigrationStepsCollection; |
||
6 | |||
7 | /** |
||
8 | * @property-read string $name |
||
9 | * @property-read string $path |
||
10 | * @property-read string $rawDefinition |
||
11 | * @property-read integer $status |
||
12 | * @property-read MigrationStepsCollection $steps |
||
13 | * @property-read string $parsingError |
||
14 | */ |
||
15 | class MigrationDefinition extends AbstractValue |
||
16 | { |
||
17 | const STATUS_TO_PARSE = 0; |
||
18 | const STATUS_PARSED = 1; |
||
19 | const STATUS_INVALID = 2; |
||
20 | |||
21 | /** @var string filename */ |
||
22 | protected $name; |
||
23 | /** @var string full path including the filename, relative to the app's root dir if contained within it */ |
||
24 | protected $path; |
||
25 | protected $rawDefinition; |
||
26 | /** @var int */ |
||
27 | protected $status = 0; |
||
28 | /** @var MigrationStepsCollection */ |
||
29 | protected $steps; |
||
30 | protected $parsingError; |
||
31 | |||
32 | /** |
||
33 | * @param string $name |
||
34 | * @param string $path |
||
35 | * @param string $rawDefinition |
||
36 | * @param int $status |
||
37 | * @param MigrationStep[]|MigrationStepsCollection $steps |
||
38 | * @param string $parsingError |
||
39 | */ |
||
40 | 149 | public function __construct($name, $path, $rawDefinition, $status = 0, $steps = array(), $parsingError = null) |
|
41 | { |
||
42 | 149 | $this->name = $name; |
|
0 ignored issues
–
show
Bug
introduced
by
![]() |
|||
43 | 149 | $this->path = $path; |
|
0 ignored issues
–
show
|
|||
44 | 149 | $this->rawDefinition = $rawDefinition; |
|
0 ignored issues
–
show
|
|||
45 | 149 | $this->status = $status; |
|
0 ignored issues
–
show
|
|||
46 | 149 | $this->steps = ($steps instanceof MigrationStepsCollection) ? $steps : new MigrationStepsCollection($steps); |
|
0 ignored issues
–
show
|
|||
47 | 149 | $this->parsingError = $parsingError; |
|
0 ignored issues
–
show
|
|||
48 | 149 | } |
|
49 | |||
50 | /** |
||
51 | * Allow the class to be serialized to php using var_export |
||
52 | * @param array $data |
||
53 | * @return static |
||
54 | */ |
||
55 | public static function __set_state(array $data) |
||
56 | { |
||
57 | return new static( |
||
58 | $data['name'], |
||
59 | $data['path'], |
||
60 | $data['rawDefinition'], |
||
61 | $data['status'], |
||
62 | $data['steps'], |
||
63 | $data['parsingError'] |
||
64 | ); |
||
65 | } |
||
66 | } |
||
67 |