This repository was archived by the owner on Jul 25, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathModule.php
More file actions
100 lines (89 loc) · 2.86 KB
/
Module.php
File metadata and controls
100 lines (89 loc) · 2.86 KB
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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
<?php
/*
* Copyright (c) 2013, Flaming Code
*
*/
namespace FlamingSms;
use Zend\ModuleManager\Feature\AutoloaderProviderInterface;
use Zend\Mvc\ModuleRouteListener;
use Zend\ModuleManager\Feature\ConsoleUsageProviderInterface;
use Zend\Console\Adapter\AdapterInterface as Console;
/**
* Module
*
* @author Flemming Andersen <flemming@flamingcode.com>
* @copyright (c) 2013, Flaming Code
* @link http://github.com/FlamingCode/FlamingSms for the canonical source repository
* @license http://opensource.org/licenses/MIT MIT
*/
class Module implements AutoloaderProviderInterface, ConsoleUsageProviderInterface
{
public function getServiceConfig()
{
return array(
'factories' => array(
'FlamingSms\SmsGateway\Factory' => function($sm) {
$config = $sm->get('Configuration');
$config = $config['flamingsms'];
return new SmsGateway\Factory($config['gateway_classmap'], $config['gateway_config']);
},
'FlamingSms\Service\SmsService' => function($sm) {
$config = $sm->get('Configuration');
$config = $config['flamingsms'];
$service = new Service\SmsService;
$service->setEntityManager($sm->get('Doctrine\ORM\EntityManager'))
->setHydrator(new \Zend\Stdlib\Hydrator\ClassMethods(false))
->setOptions($config['sms_service'])
->setGatewayFactory($sm->get('FlamingSms\SmsGateway\Factory'))
->setDefaultGatewayName($config['default_gateway_name']);
return $service;
},
)
);
}
public function getControllerPluginConfig()
{
return array(
'factories' => array(
'smsSender' => function($helpers) {
$serviceLocator = $helpers->getServiceLocator();
$smsService = $serviceLocator->get('FlamingSms\Service\SmsService');
return new Controller\Plugin\SmsSender($smsService);
},
),
);
}
public function onBootstrap($e)
{
/* @var $application \Zend\Mvc\Application */
$application = $e->getApplication();
/* @var $eventManager \Zend\EventManager\EventManager */
$eventManager = $application->getEventManager();
$moduleRouteListener = new ModuleRouteListener();
$moduleRouteListener->attach($eventManager);
/* @var $serviceManager \Zend\ServiceManager\ServiceManager */
$serviceManager = $application->getServiceManager();
}
public function getConsoleUsage(Console $console)
{
return array(
'SMS Queue Management',
'smsqueue run [-m|--send-mail] [--use-gateway=] [gateway]' => 'Run the sms queue. Optionally specify the gateway',
'smsqueue clean [-m|--send-mail] [gateway]' => 'Clean the sms queue. Optionally specify the gateway',
);
}
public function getConfig()
{
return include __DIR__ . '/config/module.config.php';
}
public function getAutoloaderConfig()
{
return array(
'Zend\Loader\StandardAutoloader' => array(
'namespaces' => array(
__NAMESPACE__ => __DIR__ . '/src/' . __NAMESPACE__,
)
)
);
}
}