ACL Extension  0.3
 All Data Structures Namespaces Files Functions Variables
Strategy.php
Go to the documentation of this file.
1 <?php
2 
11 class Strategy {
12 
18  public static $strategy = 'nestedSet.pathMaterialization';
19 
20  protected static $initialized = false;
21 
26  protected static $location = 'application.modules.acl.';
27  protected static $config = NULL;
28 
29  public static function initialize(){
30  if(!static::$initialized){
31  static::$initialized = true;
32  $strategyPath = static::$location.'.components.strategies.'.static::$strategy;
33  Yii::import($strategyPath.'.*');
34  Yii::import($strategyPath.'.models.*');
35  $config = require_once(Yii::getPathOfAlias($strategyPath.'.config').'.php');
36 
37  if(!$config)
38  throw new RuntimeException('Unable to load configuration');
39 
40  static::$config = $config;
42  }
43  }
44 
50  public static function getClass($className){
52  //If this is a global class
53  $globalClasses = array('AclObject', 'Action', 'RequestingActiveRecord',
54  'RestrictedActiveRecord', 'CGroup', 'RGroup');
55  if(in_array($className, $globalClasses))
56  return $className;
57 
58  if(substr($className, 0, strlen(static::$config['prefix'])) == static::$config['prefix'])
59  return $className;
60 
61  return static::$config['prefix'].$className;
62  }
63 
69  public static function get($propName){
70  return @static::$config[$propName];
71  }
72 
77  protected static function createShortcutClasses(){
78  eval('class CGroup extends '.static::getClass('Aco').'{}');
79  eval('class RGroup extends '.static::getClass('Aro').'{}');
80  }
81 
82 }
83 
84 ?>