-
Notifications
You must be signed in to change notification settings - Fork 0
/
SiteAccessFactory.php
44 lines (35 loc) · 1004 Bytes
/
SiteAccessFactory.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
<?php
namespace BaseXMS;
use Zend\ServiceManager\ServiceLocatorInterface;
class SiteAccessFactory
{
public static function factory( ServiceLocatorInterface $serviceLocator, $context = '' )
{
$appConfig = $serviceLocator->get( 'application' )->getConfig();
$siteaccesses = isset( $appConfig[ 'siteaccesses' ] ) ? $appConfig[ 'siteaccesses' ] : array();
$class = '\BaseXMS\SiteAccess';
if( !empty( $siteaccesses ) )
{
if( isset( $siteaccesses[ $context ] ) )
{
if( class_exists( $siteaccesses[ $context ] ) )
{
$class = $siteaccesses[ $context ];
}
else
{
$serviceLocator->get( 'log' )->warn( 'Unable to load siteaccess: ' . $class );
}
}
else
{
$serviceLocator->get( 'log' )->warn( 'Unkown siteaccess context: ' . $context );
}
}
$serviceLocator->get( 'log' )->info( 'Loading siteaccess: ' . $class );
$instance = new $class;
$instance->init( $serviceLocator );
return $instance;
}
}
?>