forked from jamiehannaford/php-opencloud-zf2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Module.php
96 lines (85 loc) · 2.65 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
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
<?php
namespace OpenCloud;
use Zend\ServiceManager\ServiceLocatorInterface;
/**
* Module config class
*
* @package OpenCloud
*/
class Module
{
/**
* @return array
*/
public function getConfig()
{
return self::getModuleConfig();
}
/**
* Static method used to retrieve config - useful for creating service manager objects in test cases.
*
* @return array Nested config structure
*/
public static function getModuleConfig()
{
return include __DIR__ . '/config/module.config.php';
}
/**
* Configures Zend's standard autoloader to find module namespaces
*
* @return array
*/
public function getAutoloaderConfig()
{
return array(
'Zend\Loader\StandardAutoloader' => array(
'namespaces' => array(
__NAMESPACE__ . '\\Zf2' => __DIR__ . '/src/',
),
),
);
}
/**
* @return array
*/
public function getServiceConfig()
{
return array(
'factories' => array(
'OpenCloud\OpenStack' => function (ServiceLocatorInterface $serviceManager) {
$builder = $serviceManager->get('ProviderBuilder');
$builder->setProvider('OpenStack');
$builder->setConfig($serviceManager->get('config'));
return $builder->build();
},
'OpenCloud\Rackspace' => function (ServiceLocatorInterface $serviceManager) {
$builder = $serviceManager->get('ProviderBuilder');
$builder->setProvider('Rackspace');
$builder->setConfig($serviceManager->get('config'));
return $builder->build();
}
),
);
}
/**
* @return array
*/
public function getViewHelperConfig()
{
return array(
'factories' => array(
'CloudFiles' => function ($pluginManager) {
$serviceManager = $pluginManager->getServiceLocator();
$client = $serviceManager->get('OpenCloud');
$config = $serviceManager->get('config');
$region = $config['opencloud']['region'];
$urlType = $config['opencloud']['url_type'];
$service = $client->objectStoreService('cloudFiles', $region, $urlType);
$helper = new \OpenCloud\Zf2\Helper\CloudFilesHelper($service);
$pluginManager->injectRenderer($helper);
return $helper;
}
),
);
}
}