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
|
public function getServiceConfig()
{
return array(
'factories' => array(
'cache' => function () {
return \Zend\Cache\StorageFactory::factory(array(
'adapter' => array(
'name' => 'filesystem',
'options' => array(
'cache_dir' => __DIR__ . '/../../data/cache',
'ttl' => 100
),
),
'plugins' => array(
array(
'name' => 'serializer',
'options' => array(
)
)
)
));
},
'acl' => function ($sm) {
$cache = $sm->get('cache');
$acl = $cache->getItem('acl');
if (!$acl) {
$config = $sm->get('config');
$acl = new Acl();
if (isset($config['acl'])) {
if (isset($config['acl']['resources'])) {
foreach ($config['acl']['resources'] as $string) {
$acl->addResource($string);
}
}
if (isset($config['acl']['roles'])) {
foreach ($config['acl']['roles'] as $string) {
$acl->addRole($string);
}
}
if (isset($config['acl']['allow'])) {
foreach ($config['acl']['allow'] as $row) {
$acl->allow($row['role'], $row['resource'], $row['action']);
}
}
}
$cache->setItem('acl', serialize($acl));
} else {
$acl = unserialize($acl);
}
return $acl;
},
),
);
} |
Partager