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
|
|
|
'Initialize migrations', |
64
|
|
|
'migration init' => 'Check config, create table `migrations`', |
65
|
|
|
|
66
|
|
|
'Get last applied migration version', |
67
|
|
|
'migration version [<name>]' => '', |
68
|
|
|
['[<name>]', 'specify which configured migrations to run, defaults to `default`'], |
69
|
|
|
|
70
|
|
|
'List available migrations', |
71
|
|
|
'migration list [<name>] [--all]' => '', |
72
|
|
|
['--all', 'Include applied migrations'], |
73
|
|
|
['[<name>]', 'specify which configured migrations to run, defaults to `default`'], |
74
|
|
|
|
75
|
|
|
'Generate new migration skeleton class', |
76
|
|
|
'migration generate [<name>]' => '', |
77
|
|
|
['[<name>]', 'specify which configured migrations to run, defaults to `default`'], |
78
|
|
|
|
79
|
|
|
'Execute migration', |
80
|
|
|
'migration apply [<name>] [<version>] [--force] [--down]' => '', |
81
|
|
|
['[<name>]', 'specify which configured migrations to run, defaults to `default`'], |
82
|
|
|
[ |
83
|
|
|
'--force', |
84
|
|
|
'Force apply migration even if it\'s older than the last migrated.' |
85
|
|
|
.' Works only with <version> explicitly set.' |
86
|
|
|
], |
87
|
|
|
[ |
88
|
|
|
'--down', |
89
|
|
|
'Force apply down migration. Works only with --force flag set.' |
90
|
|
|
], |
91
|
|
|
]; |
92
|
|
|
} |
93
|
|
|
} |
94
|
|
|
|