/** * constructor; sets up the Zend Acl object * * @return void * @author Andy Bennett */ function __construct() { $this->acl = new Zend_Acl(); $this->conf = Kohana::config('acl.acl'); // initialise the roles from the list foreach ($this->conf->roles as $role => $inherit) { $this->acl->addRole(new Zend_Acl_Role($role)); } // initialise the resources from the config foreach ($this->conf->resources as $resource) { $this->acl->add(new Zend_Acl_Resource($resource)); } // initialise the resources from the config foreach ($this->conf->allowed as $allowed) { $r = isset($allowed['resource']) ? $allowed['resource'] : null; $a = isset($allowed['actions']) ? $allowed['actions'] : null; $this->acl->allow($allowed['role'], $r, $a); } // initialise the resources from the config foreach ($this->conf->denied as $denied) { $r = isset($denied['resource']) ? $denied['resource'] : null; $a = isset($denied['actions']) ? $denied['actions'] : null; $this->acl->deny($denied['role'], $r, $a); } // Singleton instance self::$instance = $this; }
/** * Returns a singleton instance of acl. * * @return object */ public static function &instance() { if (!isset(self::$instance)) { $class = __CLASS__; self::$instance = new $class(); } return self::$instance; }