-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathModule.php
More file actions
63 lines (53 loc) · 1.91 KB
/
Module.php
File metadata and controls
63 lines (53 loc) · 1.91 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
<?php
/**
* Zend Framework (http://framework.zend.com/)
*
* @link http://github.com/zendframework/Facebook for the canonical source repository
* @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
namespace FacebookApi;
use Zend\Mvc\ModuleRouteListener;
use Zend\Mvc\MvcEvent;
use Zend\ServiceManager\ServiceManager;
class Module
{
public function getConfig()
{
return include __DIR__ . '/config/module.config.php';
}
public function onBootstrap(MvcEvent $e)
{
$eventManager = $e->getApplication()->getEventManager();
$moduleRouteListener = new ModuleRouteListener();
$eventManager->attach('route', array($this, 'onPreRoute'), 100);
//$eventManager->attach('', array($this, 'onFacebookApiCall'), 100);
$moduleRouteListener->attach($eventManager);
$this->onFacebookApiCall($e);
}
// Translaton routing
public function onPreRoute($e){
$application = $e->getApplication();
$serviceManager = $application->getServiceManager();
$serviceManager->get('router')->setTranslator($serviceManager->get('translator'));
}
// Facebook Graph Api get
public function onFacebookApiCall($e){
$application = $e->getApplication();
/**
* @var $sm ServiceManager
*/
$sm = $application->getServiceManager();
$sharedManager = $application->getEventManager()->getSharedManager();
// Has a Logger
if($sm->has('jhu.zdt_logger')){
$sharedManager->attach('FbBasic\Service\FacebookAbstract', 'get.pre',
function($e) use ($sm) {
if ($e->getParam('endpoint')){
$sm->get('jhu.zdt_logger')->info($e->getParam('endpoint'));
}
}
);
}
}
}