-
Notifications
You must be signed in to change notification settings - Fork 0
/
Module.php
64 lines (52 loc) · 1.87 KB
/
Module.php
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
<?php
namespace FourSquareModule;
use PPI\Module\RoutesProviderInterface,
PPI\Module\Module as BaseModule,
PPI\Autoload,
PPI\Module\Service;
class Module extends BaseModule
{
protected $_moduleName = 'FoursquareModule';
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()
{
return include(__DIR__ . '/resources/config/config.php');
}
public function getServiceConfig()
{
return array('factories' => array(
// Create a service named foursquare.handler and map it to this lazy-loaded closure
// this is called from the controller. The code in this function is not called until a
// getService() call from a controller happens or if another service invokes it.
'foursquare.handler' => function($sm) {
// Construct the Api Handler and cache objects
$handler = new \FoursquareModule\Classes\ApiHandler();
$cache = new \Doctrine\Common\Cache\ApcCache();
// Pull the config data from the service manager ($sm)
$config = $sm->get('config');
// Call the setters on the ApiHandler, passing in its dependencies
$handler->setSecret($config['foursquare']['secret']);
$handler->setKey($config['foursquare']['key']);
$handler->setCache($cache);
return $handler;
}
));
}
}