|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace T4web\Migrations; |
|
4
|
|
|
|
|
5
|
|
|
use Zend\ModuleManager\Feature\ConfigProviderInterface; |
|
6
|
|
|
use Zend\ModuleManager\Feature\AutoloaderProviderInterface; |
|
7
|
|
|
use Zend\ModuleManager\Feature\ConsoleUsageProviderInterface; |
|
8
|
|
|
use Zend\Console\Adapter\AdapterInterface; |
|
9
|
|
|
|
|
10
|
|
|
class Module implements ConfigProviderInterface, AutoloaderProviderInterface, ConsoleUsageProviderInterface |
|
11
|
|
|
{ |
|
12
|
|
|
|
|
13
|
|
|
/** |
|
14
|
|
|
* Returns configuration to merge with application configuration |
|
15
|
|
|
* |
|
16
|
|
|
* @return array|\Traversable |
|
17
|
|
|
*/ |
|
18
|
|
|
public function getConfig() |
|
19
|
|
|
{ |
|
20
|
|
|
return include dirname(__DIR__) . '/config/module.config.php'; |
|
21
|
|
|
} |
|
22
|
|
|
|
|
23
|
|
|
/** |
|
24
|
|
|
* Return an array for passing to Zend\Loader\AutoloaderFactory. |
|
25
|
|
|
* |
|
26
|
|
|
* @return array |
|
27
|
|
|
*/ |
|
28
|
|
|
public function getAutoloaderConfig() |
|
29
|
|
|
{ |
|
30
|
|
|
return [ |
|
31
|
|
|
'Zend\Loader\StandardAutoloader' => [ |
|
32
|
|
|
'namespaces' => [ |
|
33
|
|
|
__NAMESPACE__ => dirname(__DIR__) . '/src', |
|
34
|
|
|
], |
|
35
|
|
|
], |
|
36
|
|
|
]; |
|
37
|
|
|
} |
|
38
|
|
|
|
|
39
|
|
|
/** |
|
40
|
|
|
* Returns an array or a string containing usage information for this module's Console commands. |
|
41
|
|
|
* The method is called with active Zend\Console\Adapter\AdapterInterface that can be used to directly access |
|
42
|
|
|
* Console and send output. |
|
43
|
|
|
* |
|
44
|
|
|
* If the result is a string it will be shown directly in the console window. |
|
45
|
|
|
* If the result is an array, its contents will be formatted to console window width. The array must |
|
46
|
|
|
* have the following format: |
|
47
|
|
|
* |
|
48
|
|
|
* return array( |
|
49
|
|
|
* 'Usage information line that should be shown as-is', |
|
50
|
|
|
* 'Another line of usage info', |
|
51
|
|
|
* |
|
52
|
|
|
* '--parameter' => 'A short description of that parameter', |
|
53
|
|
|
* '-another-parameter' => 'A short description of another parameter', |
|
54
|
|
|
* ... |
|
55
|
|
|
* ) |
|
56
|
|
|
* |
|
57
|
|
|
* @param AdapterInterface $console |
|
58
|
|
|
* @return array|string|null |
|
59
|
|
|
*/ |
|
60
|
|
|
public function getConsoleUsage(AdapterInterface $console) |
|
61
|
|
|
{ |
|
62
|
|
|
return [ |
|
63
|
|
|
'Get last applied migration version', |
|
64
|
|
|
'migration version [<name>]' => '', |
|
65
|
|
|
['[<name>]', 'specify which configured migrations to run, defaults to `default`'], |
|
66
|
|
|
|
|
67
|
|
|
'List available migrations', |
|
68
|
|
|
'migration list [<name>] [--all]' => '', |
|
69
|
|
|
['--all', 'Include applied migrations'], |
|
70
|
|
|
['[<name>]', 'specify which configured migrations to run, defaults to `default`'], |
|
71
|
|
|
|
|
72
|
|
|
'Generate new migration skeleton class', |
|
73
|
|
|
'migration generate [<name>]' => '', |
|
74
|
|
|
['[<name>]', 'specify which configured migrations to run, defaults to `default`'], |
|
75
|
|
|
|
|
76
|
|
|
'Execute migration', |
|
77
|
|
|
'migration apply [<name>] [<version>] [--force] [--down] [--fake]' => '', |
|
78
|
|
|
['[<name>]', 'specify which configured migrations to run, defaults to `default`'], |
|
79
|
|
|
[ |
|
80
|
|
|
'--force', |
|
81
|
|
|
'Force apply migration even if it\'s older than the last migrated.' |
|
82
|
|
|
.' Works only with <version> explicitly set.' |
|
83
|
|
|
], |
|
84
|
|
|
[ |
|
85
|
|
|
'--down', |
|
86
|
|
|
'Force apply down migration. Works only with --force flag set.' |
|
87
|
|
|
], |
|
88
|
|
|
[ |
|
89
|
|
|
'--fake', |
|
90
|
|
|
'Fake apply or apply down migration.' |
|
91
|
|
|
.' Adds/removes migration to the list of applied w/out really applying it.' |
|
92
|
|
|
.' Works only with <version> explicitly set.' |
|
93
|
|
|
], |
|
94
|
|
|
]; |
|
95
|
|
|
} |
|
96
|
|
|
} |
|
97
|
|
|
|