Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
<?php
namespace Breyta;
use Breyta\Model\Migration;
use Breyta\Model\Statement;
/**
* Class CallbackProgress
*
* Stores callbacks for migration progress.
*
* @package Breyta
* @author Thomas Flori <thflori@gmail.com>
* @codeCoverageIgnore This class has no own code it just stores callbacks
*/
class CallbackProgress implements ProgressInterface
{
/** @var callable */
protected $startCallback;
/** @var callable */
protected $beforeMigrationCallback;
/** @var callable */
protected $beforeExecutionCallback;
/** @var callable */
protected $afterExecutionCallback;
/** @var callable */
protected $afterMigrationCallback;
/** @var callable */
protected $finishCallback;
/**
* Output information about starting the migration process
*
* Info contains:
* - `migrations` - an array of Breyta\Model\Migration
* - `count` - an integer how many migrations are going to be executed
*
* @param \stdClass $info
*/
public function start(\stdClass $info)
{
!$this->startCallback || call_user_func($this->startCallback, $info);
}
public function onStart(callable $callback): self
{
$this->startCallback = $callback;
return $this;
}
/**
* Output information about the $migration (before the migration)
*
* @param Migration $migration
*/
public function beforeMigration(Migration $migration)
{
!$this->beforeMigrationCallback || call_user_func($this->beforeMigrationCallback, $migration);
}
public function onBeforeMigration(callable $callback): self
{
$this->beforeMigrationCallback = $callback;
return $this;
}
/**
* Output information about the $statement (before it gets executed)
*
* @param Statement $statement
public function beforeExecution(Statement $statement)
!$this->beforeExecutionCallback || call_user_func($this->beforeExecutionCallback, $statement);
}
public function onBeforeExecution(callable $callback): self
{
$this->beforeExecutionCallback = $callback;
return $this;
}
/**
* Output information about the $statement (after it gets executed)
*
* @param Statement $statement
public function afterExecution(Statement $statement)
!$this->afterExecutionCallback || call_user_func($this->afterExecutionCallback, $statement);
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
}
public function onAfterExecution(callable $callback): self
{
$this->afterExecutionCallback = $callback;
return $this;
}
/**
* Output information about the $migration (after the migration)
*
* @param Migration $migration
*/
public function afterMigration(Migration $migration)
{
!$this->afterMigrationCallback || call_user_func($this->afterMigrationCallback, $migration);
}
public function onAfterMigration(callable $callback): self
{
$this->afterMigrationCallback = $callback;
return $this;
}
/**
* Output information about what just happened
*
* Info contains:
* - `migrations` - an array of Breyta\Model\Migration
* - `executed` - an array of migrations that just got executed
*
* @param \stdClass $info
*/
public function finish(\stdClass $info)
{
!$this->finishCallback || call_user_func($this->finishCallback, $info);
}
public function onFinish(callable $callback): self
{
$this->finishCallback = $callback;
return $this;
}
}