|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* Platine ETL |
|
5
|
|
|
* |
|
6
|
|
|
* Platine ETL is a library to Extract-Transform-Load Data from various sources |
|
7
|
|
|
* |
|
8
|
|
|
* This content is released under the MIT License (MIT) |
|
9
|
|
|
* |
|
10
|
|
|
* Copyright (c) 2020 Platine ETL |
|
11
|
|
|
* Copyright (c) 2019 Benoit POLASZEK |
|
12
|
|
|
* |
|
13
|
|
|
* Permission is hereby granted, free of charge, to any person obtaining a copy |
|
14
|
|
|
* of this software and associated documentation files (the "Software"), to deal |
|
15
|
|
|
* in the Software without restriction, including without limitation the rights |
|
16
|
|
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
|
17
|
|
|
* copies of the Software, and to permit persons to whom the Software is |
|
18
|
|
|
* furnished to do so, subject to the following conditions: |
|
19
|
|
|
* |
|
20
|
|
|
* The above copyright notice and this permission notice shall be included in all |
|
21
|
|
|
* copies or substantial portions of the Software. |
|
22
|
|
|
* |
|
23
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
|
24
|
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
|
25
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
|
26
|
|
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
|
27
|
|
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
|
28
|
|
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
|
29
|
|
|
* SOFTWARE. |
|
30
|
|
|
*/ |
|
31
|
|
|
|
|
32
|
|
|
declare(strict_types=1); |
|
33
|
|
|
|
|
34
|
|
|
namespace Platine\Etl\Event; |
|
35
|
|
|
|
|
36
|
|
|
use Platine\Etl\Etl; |
|
37
|
|
|
use Platine\Event\Event; |
|
38
|
|
|
|
|
39
|
|
|
/** |
|
40
|
|
|
* @class BaseEvent |
|
41
|
|
|
* @package Platine\Etl\Event |
|
42
|
|
|
*/ |
|
43
|
|
|
class BaseEvent extends Event |
|
44
|
|
|
{ |
|
45
|
|
|
/** |
|
46
|
|
|
* Fired at the very beginning of the process. |
|
47
|
|
|
*/ |
|
48
|
|
|
public const START = 'start'; |
|
49
|
|
|
|
|
50
|
|
|
/** |
|
51
|
|
|
* Fired after an item has been extracted. |
|
52
|
|
|
*/ |
|
53
|
|
|
public const EXTRACT = 'extract'; |
|
54
|
|
|
|
|
55
|
|
|
/** |
|
56
|
|
|
* Fired when extracting an item resulted in an exception. |
|
57
|
|
|
*/ |
|
58
|
|
|
public const EXTRACT_EXCEPTION = 'extract.exception'; |
|
59
|
|
|
|
|
60
|
|
|
/** |
|
61
|
|
|
* Fired after an item has been transformed. |
|
62
|
|
|
*/ |
|
63
|
|
|
public const TRANSFORM = 'transform'; |
|
64
|
|
|
|
|
65
|
|
|
/** |
|
66
|
|
|
* Fired when transforming an item resulted in an exception. |
|
67
|
|
|
*/ |
|
68
|
|
|
public const TRANSFORM_EXCEPTION = 'transform.exception'; |
|
69
|
|
|
|
|
70
|
|
|
/** |
|
71
|
|
|
* This event is fired when initializing the loader (just before the 1st item gets loaded). |
|
72
|
|
|
*/ |
|
73
|
|
|
public const LOADER_INIT = 'loader.init'; |
|
74
|
|
|
|
|
75
|
|
|
/** |
|
76
|
|
|
* Fired after an item has been loaded. |
|
77
|
|
|
*/ |
|
78
|
|
|
public const LOAD = 'load'; |
|
79
|
|
|
|
|
80
|
|
|
/** |
|
81
|
|
|
* Fired when loading an item resulted in an exception. |
|
82
|
|
|
*/ |
|
83
|
|
|
public const LOAD_EXCEPTION = 'load.exception'; |
|
84
|
|
|
|
|
85
|
|
|
/** |
|
86
|
|
|
* Fired after an item has been skipped. |
|
87
|
|
|
*/ |
|
88
|
|
|
public const SKIP = 'skip'; |
|
89
|
|
|
|
|
90
|
|
|
/** |
|
91
|
|
|
* Fired after an item required the ETL to stop. |
|
92
|
|
|
*/ |
|
93
|
|
|
public const STOP = 'stop'; |
|
94
|
|
|
|
|
95
|
|
|
/** |
|
96
|
|
|
* Fired after a flush operation has been completed. |
|
97
|
|
|
*/ |
|
98
|
|
|
public const FLUSH = 'flush'; |
|
99
|
|
|
|
|
100
|
|
|
/** |
|
101
|
|
|
* Fired after a rollback operation has been completed. |
|
102
|
|
|
*/ |
|
103
|
|
|
public const ROLLBACK = 'rollback'; |
|
104
|
|
|
|
|
105
|
|
|
/** |
|
106
|
|
|
* Fired at the end of the ETL process. |
|
107
|
|
|
*/ |
|
108
|
|
|
public const END = 'end'; |
|
109
|
|
|
|
|
110
|
|
|
/** |
|
111
|
|
|
* The ETL instance |
|
112
|
|
|
* @var Etl |
|
113
|
|
|
*/ |
|
114
|
|
|
protected Etl $etl; |
|
115
|
|
|
|
|
116
|
|
|
/** |
|
117
|
|
|
* Create new instance |
|
118
|
|
|
* @param string $name |
|
119
|
|
|
* @param Etl $etl |
|
120
|
|
|
*/ |
|
121
|
|
|
public function __construct(string $name, Etl $etl) |
|
122
|
|
|
{ |
|
123
|
|
|
parent::__construct($name); |
|
124
|
|
|
$this->etl = $etl; |
|
125
|
|
|
} |
|
126
|
|
|
|
|
127
|
|
|
/** |
|
128
|
|
|
* Return ETL instance |
|
129
|
|
|
* @return Etl |
|
130
|
|
|
*/ |
|
131
|
|
|
public function getEtl(): Etl |
|
132
|
|
|
{ |
|
133
|
|
|
return $this->etl; |
|
134
|
|
|
} |
|
135
|
|
|
} |
|
136
|
|
|
|