1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Newage\Generators; |
4
|
|
|
|
5
|
|
|
use Zend\Mvc\ModuleRouteListener; |
6
|
|
|
use Zend\Mvc\MvcEvent; |
7
|
|
|
use Zend\Console\Adapter\AdapterInterface as Console; |
8
|
|
|
use Zend\ModuleManager\Feature\AutoloaderProviderInterface; |
9
|
|
|
use Zend\ModuleManager\Feature\ConfigProviderInterface; |
10
|
|
|
use Zend\ModuleManager\Feature\ConsoleUsageProviderInterface; |
11
|
|
|
|
12
|
|
|
/** |
13
|
|
|
* |
14
|
|
|
* @author V.Leontiev <[email protected]> |
15
|
|
|
* @license http://opensource.org/licenses/MIT MIT |
16
|
|
|
* @since php 5.5 or higher |
17
|
|
|
* @see https://github.com/newage/generators |
18
|
|
|
*/ |
19
|
|
|
class Module implements |
20
|
|
|
AutoloaderProviderInterface, |
21
|
|
|
ConfigProviderInterface, |
22
|
|
|
ConsoleUsageProviderInterface |
23
|
|
|
{ |
24
|
|
|
public function onBootstrap(MvcEvent $e) |
25
|
|
|
{ |
26
|
|
|
$eventManager = $e->getApplication()->getEventManager(); |
27
|
|
|
$moduleRouteListener = new ModuleRouteListener(); |
28
|
|
|
$moduleRouteListener->attach($eventManager); |
29
|
|
|
} |
30
|
|
|
|
31
|
|
|
/** |
32
|
|
|
* Create documentation for console usage that module |
33
|
|
|
* |
34
|
|
|
* @param Console $console |
35
|
|
|
* @return array|null|string |
36
|
|
|
*/ |
37
|
|
|
public function getConsoleUsage(Console $console) |
38
|
|
|
{ |
39
|
|
|
$docs = [ |
40
|
|
|
'Code generate:', |
41
|
|
|
'generate template <template> <destination> --namespace= --name=' => 'Generate code from a template', |
42
|
|
|
['<template>', 'A template name from a config'], |
43
|
|
|
['<destination>', 'A destination path for a generated code'], |
44
|
|
|
['--namespace', 'Namespace'], |
45
|
|
|
['--name', 'Class name'], |
46
|
|
|
]; |
47
|
|
|
return $docs; |
48
|
|
|
} |
49
|
|
|
|
50
|
|
|
/** |
51
|
|
|
* @inheritdoc |
52
|
|
|
*/ |
53
|
|
|
public function getConfig() |
54
|
|
|
{ |
55
|
|
|
$config = require_once __DIR__ . '/config/module.config.php'; |
56
|
|
|
return $config; |
57
|
|
|
} |
58
|
|
|
|
59
|
|
|
public function getAutoloaderConfig() |
60
|
|
|
{ |
61
|
|
|
return array( |
62
|
|
|
'Zend\Loader\StandardAutoloader' => array( |
63
|
|
|
'namespaces' => array( |
64
|
|
|
__NAMESPACE__ => __DIR__, |
65
|
|
|
), |
66
|
|
|
), |
67
|
|
|
); |
68
|
|
|
} |
69
|
|
|
} |
70
|
|
|
|