Skip to content

Instantly share code, notes, and snippets.

@alfrekjv
Created February 16, 2016 23:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alfrekjv/2ac2e56d539dc1fa6b2f to your computer and use it in GitHub Desktop.
Save alfrekjv/2ac2e56d539dc1fa6b2f to your computer and use it in GitHub Desktop.
<?php
namespace Application;
use PPI\Module\RoutesProviderInterface,
PPI\Module\Module as BaseModule,
PPI\Autoload,
PPI\Module\Service;
class Module extends BaseModule
{
protected $_moduleName = 'Application';
public function init($e)
{
Autoload::add(__NAMESPACE__, dirname(__DIR__));
}
/**
* Get the routes for this module
*
* @return \Symfony\Component\Routing\RouteCollection
*/
public function getRoutes()
{
return $this->loadYamlRoutes(__DIR__ . '/resources/config/routes.yml');
}
/**
* Get the configuration for this module
*
* @return array
*/
public function getConfig()
{
switch ($_SERVER['SERVER_NAME']) {
case 'localhost':
$config = __DIR__ . '/resources/config/local.config.php';
break;
default:
$config = __DIR__ . '/resources/config/production.config.php';
break;
}
return include($config);
}
public function getServiceConfig()
{
return array('factories' => array(
'token.helper' => function($sm) {
return new \Application\Classes\TokenHelper();
},
'bcrypt.hasher' => function($sm) {
return new \Application\Classes\BcryptHasher();
},
'email.helper' => function($sm) {
$config = $sm->get('config');
$transport = \Swift_SmtpTransport::newInstance($config['mailer']['host'],
$config['mailer']['port'],
$config['mailer']['protocol'])
->setUsername($config['mailer']['username'])
->setPassword($config['mailer']['password']);
return new \Application\Classes\EmailHelper($transport);
},
'stripe.driver' => function($sm) {
$config = $sm->get('config');
$driver = new \Application\Classes\Payment\Drivers\Stripe();
\Stripe::setApiKey($config['stripe']['key']);
return $driver;
},
'mcapi' => function($sm) {
$config = $sm->get('config');
$key = $config['mailchimp'];
return new \Application\Classes\MCAPI($key);
},
'api.helper' => function($sm) {
$helper = new \Application\Classes\ApiHelper();
$helper->setHttpClient(new \Guzzle\Http\Client('/'));
return $helper;
}
));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment