This repository has been 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
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 019af97
Showing
24 changed files
with
2,436 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,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 <[email protected]> | ||
* @copyright (c) 2013, Flaming Code | ||
* @link http://github.com/FlamingCode/FlamingSms for the canonical source repository | ||
* @license http://opensource.org/licenses/GPL-2.0 GPL-2.0 | ||
*/ | ||
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__, | ||
) | ||
) | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
{ | ||
"name": "flaming-code/flaming-sms", | ||
"description": "Module that provides sms sending functionality for ZF2 applications", | ||
"type": "library", | ||
"license": "GPL-2.0", | ||
"homepage": "https://github.com/FlamingCode/FlamingSms", | ||
"keywords": [ | ||
"flamingsms", | ||
"module", | ||
"zf2", | ||
"zend" | ||
], | ||
"authors": [ | ||
{ | ||
"name": "Flemming Andersen", | ||
"email": "[email protected]", | ||
"homepage": "http://flamingcode.com/" | ||
} | ||
], | ||
"minimum-stability": "dev", | ||
"require": { | ||
"php": ">=5.3.3", | ||
"zendframework/zend-loader": "2.*", | ||
"zendframework/zend-modulemanager": "2.*", | ||
"zendframework/zend-mvc": "2.*", | ||
"zendframework/zend-servicemanager": "2.*" | ||
}, | ||
"require-dev": { | ||
"phpunit/phpunit": "~3.7", | ||
"zendframework/zendframework": "2.*" | ||
}, | ||
"suggest": { | ||
}, | ||
"autoload": { | ||
"psr-0": { | ||
"FlamingBase\\": "src/" | ||
}, | ||
"classmap": [ | ||
"./" | ||
] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<?php | ||
|
||
return array( | ||
'flamingsms' => array( | ||
'sms_service' => array( | ||
'outgoing_sms_entity' => 'FlamingSms\Entity\OutgoingSms', | ||
'incomming_sms_entity' => 'FlamingSms\Entity\IncommingSms', | ||
), | ||
|
||
'default_gateway_name' => 'coolsms', | ||
|
||
// Key-value pairs of gateway names and gateway classes | ||
'gateway_classmap' => array( | ||
'coolsms' => 'FlamingSms\SmsGateway\CoolSms', | ||
'fakegw' => 'FlamingSms\SmsGateway\FakeGw', | ||
) | ||
) | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<?php | ||
|
||
return array( | ||
'flamingsms' => array( | ||
'gateway_config' => array( | ||
'coolsms' => array( | ||
'url' => 'https://sms.coolsmsc.dk', | ||
|
||
// These should be set in a *.local.php config file | ||
'username' => 'myusername', | ||
'password' => 'mypassword', | ||
'notification_url' => 'http://my-url.invalid/notification/coolsms' | ||
), | ||
|
||
// For testing purposes you can make your own "gateway" by just saving the messages to a DB | ||
'fakegw' => array( | ||
'url' => '', | ||
'username' => '', | ||
'password' => '', | ||
'notification_url' => 'http://my-url.invalid/notification/gwexample' | ||
), | ||
) | ||
) | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,144 @@ | ||
<?php | ||
namespace FlamingSms; | ||
|
||
return array( | ||
'controllers' => array( | ||
'invokables' => array( | ||
'FlamingSms\Controller\Incomming' => 'FlamingSms\Controller\IncommingController', | ||
'FlamingSms\Controller\Notification' => 'FlamingSms\Controller\NotificationController', | ||
|
||
// Console controllers | ||
'FlamingSms\Cli\SmsQueue' => 'FlamingSms\Cli\SmsQueueController', | ||
) | ||
), | ||
|
||
'router' => array( | ||
'routes' => array( | ||
'flamingsms' => array( | ||
'type' => 'Literal', | ||
'options' => array( | ||
'route' => '/sms', | ||
'defaults' => array( | ||
'__NAMESPACE__' => 'FlamingSms\Controller', | ||
'controller' => 'Index', | ||
'action' => 'index', | ||
), | ||
), | ||
'may_terminate' => true, | ||
'child_routes' => array( | ||
'incomming' => array( | ||
'type' => 'segment', | ||
'options' => array( | ||
'route' => '/incomming[/:action]', | ||
'constraints' => array( | ||
'action' => '[a-zA-Z][a-zA-Z0-9_-]*', | ||
), | ||
'defaults' => array( | ||
'controller' => 'Incomming', | ||
'action' => 'index' | ||
) | ||
) | ||
), | ||
|
||
'notification' => array( | ||
'type' => 'segment', | ||
'options' => array( | ||
'route' => '/notification[/:action]', | ||
'constraints' => array( | ||
'action' => '[a-zA-Z][a-zA-Z0-9_-]*', | ||
), | ||
'defaults' => array( | ||
'controller' => 'Notification', | ||
'action' => 'index' | ||
) | ||
) | ||
), | ||
) | ||
) | ||
) | ||
), | ||
|
||
'console' => array( | ||
'router' => array( | ||
'routes' => array( | ||
'smsqueue-run' => array( | ||
'options' => array( | ||
'route' => 'smsqueue run [-m|--send-mail] [--use-gateway=] [<gatewayname>]', | ||
'defaults' => array( | ||
'controller' => 'FlamingSms\Cli\Smsqueue', | ||
'action' => 'run' | ||
) | ||
) | ||
), | ||
|
||
'smsqueue-clean' => array( | ||
'options' => array( | ||
'route' => 'smsqueue clean [-m|--send-mail] [<gatewayname>]', | ||
'defaults' => array( | ||
'controller' => 'FlamingSms\Cli\SmsQueue', | ||
'action' => 'clean' | ||
) | ||
) | ||
), | ||
) | ||
) | ||
), | ||
|
||
// Doctrine config | ||
'doctrine' => array( | ||
'driver' => array( | ||
__NAMESPACE__ . '_driver' => array( | ||
'class' => 'Doctrine\ORM\Mapping\Driver\AnnotationDriver', | ||
'cache' => 'array', | ||
'paths' => array(__DIR__ . '/../src/' . __NAMESPACE__ . '/Entity') | ||
), | ||
'orm_default' => array( | ||
'drivers' => array( | ||
__NAMESPACE__ . '\Entity' => __NAMESPACE__ . '_driver' | ||
) | ||
) | ||
) | ||
), | ||
|
||
'flamingsms' => array( | ||
'sms_service' => array( | ||
'outgoing_sms_entity' => 'FlamingSms\Entity\OutgoingSms', | ||
'incomming_sms_entity' => 'FlamingSms\Entity\IncommingSms', | ||
), | ||
|
||
'default_gateway_name' => 'coolsms', | ||
|
||
// Key-value pairs of gateway names and gateway classes | ||
'gateway_classmap' => array( | ||
'coolsms' => 'FlamingSms\SmsGateway\CoolSms', | ||
'fakegw' => 'FlamingSms\SmsGateway\FakeGw', | ||
), | ||
|
||
'gateway_config' => array( | ||
'coolsms' => array( | ||
'url' => 'https://sms.coolsmsc.dk', | ||
|
||
// These should be set in a *.local.php config file | ||
'username' => 'myusername', | ||
'password' => 'mypassword', | ||
'notification_url' => 'http://my-url.invalid/notification/coolsms' | ||
), | ||
|
||
// For testing purposes you can make your own "gateway" by just saving the messages to a DB | ||
'fakegw' => array( | ||
'url' => '', | ||
'username' => '', | ||
'password' => '', | ||
'notification_url' => 'http://my-url.invalid/notification/gwexample' | ||
), | ||
) | ||
), | ||
|
||
// 'error_handler' => array( | ||
// 'send_mail' => false, | ||
// 'mail_options' => array( | ||
// 'to' => '[email protected]', | ||
// 'subject' => 'Exception mail' | ||
// ) | ||
// ), | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
CREATE TABLE `incommingSmses` ( | ||
`id` int(10) unsigned NOT NULL AUTO_INCREMENT, | ||
`phone` char(10) COLLATE utf8_general_ci NOT NULL, | ||
`content` text COLLATE utf8_general_ci NOT NULL, | ||
`shortcode` varchar(10) COLLATE utf8_general_ci NOT NULL, | ||
`receivedTime` datetime NOT NULL, | ||
PRIMARY KEY (`id`), | ||
KEY `phone` (`phone`) | ||
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
CREATE TABLE `outgoingSmses` ( | ||
`id` int(10) unsigned NOT NULL AUTO_INCREMENT, | ||
`gatewayName` varchar(100) COLLATE utf8_general_ci NOT NULL, | ||
`gatewayId` varchar(100) COLLATE utf8_general_ci DEFAULT NULL, | ||
`content` text COLLATE utf8_general_ci NOT NULL, | ||
`partCount` tinyint(3) unsigned NOT NULL DEFAULT '1', | ||
`receiver` char(10) COLLATE utf8_general_ci NOT NULL, | ||
`senderId` varchar(20) COLLATE utf8_general_ci NOT NULL, | ||
`status` varchar(100) COLLATE utf8_general_ci NOT NULL, | ||
`sendTime` datetime DEFAULT NULL, | ||
`sentTime` datetime DEFAULT NULL, | ||
`deliveredTime` datetime DEFAULT NULL, | ||
`parentSms_id` int(10) unsigned DEFAULT NULL, | ||
PRIMARY KEY (`id`), | ||
UNIQUE KEY `gateway_id` (`gatewayId`), | ||
KEY `parentSms_id` (`parentSms_id`), | ||
KEY `gatewayName` (`gatewayName`), | ||
KEY `status` (`status`) | ||
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci; | ||
|
||
ALTER TABLE `outgoingSmses` | ||
ADD CONSTRAINT `outgoingSmsParent` FOREIGN KEY (`parentSms_id`) REFERENCES `outgoingSmses` (`id`) ON DELETE SET NULL; |
Oops, something went wrong.