| 1 |
|
<?php |
| 2 |
|
/** |
| 3 |
|
* Xyster Framework |
| 4 |
|
* |
| 5 |
|
* This source file is subject to the new BSD license that is bundled |
| 6 |
|
* with this package in the file LICENSE.txt. |
| 7 |
|
* It is also available through the world-wide-web at this URL: |
| 8 |
|
* http://www.opensource.org/licenses/bsd-license.php |
| 9 |
|
* |
| 10 |
|
* @category Xyster |
| 11 |
|
* @package Xyster_Orm |
| 12 |
|
* @subpackage Plugins |
| 13 |
|
* @copyright Copyright (c) 2007-2008 Irrational Logic (http://irrationallogic.net) |
| 14 |
|
* @license http://www.opensource.org/licenses/bsd-license.php New BSD License |
| 15 |
|
* @version $Id: Acl.php 202 2008-01-20 16:20:09Z doublecompile $ |
| 16 |
|
*/ |
| 17 |
|
/** |
| 18 |
|
* @see Xyster_Orm_Plugin_Abstract |
| 19 |
|
*/ |
| 20 |
1 |
require_once 'Xyster/Orm/Plugin/Abstract.php'; |
| 21 |
|
/** |
| 22 |
|
* The base ORM plugin object |
| 23 |
|
* |
| 24 |
|
* @category Xyster |
| 25 |
|
* @package Xyster_Orm |
| 26 |
|
* @subpackage Plugins |
| 27 |
|
* @copyright Copyright (c) 2007-2008 Irrational Logic (http://irrationallogic.net) |
| 28 |
|
* @license http://www.opensource.org/licenses/bsd-license.php New BSD License |
| 29 |
|
*/ |
| 30 |
|
class Xyster_Orm_Plugin_Acl extends Xyster_Orm_Plugin_Abstract |
| 31 |
|
{ |
| 32 |
|
/** |
| 33 |
|
* The access control list |
| 34 |
|
* |
| 35 |
|
* @var Zend_Acl |
| 36 |
|
*/ |
| 37 |
|
protected $_acl; |
| 38 |
|
|
| 39 |
|
/** |
| 40 |
|
* Creates a new ACL plugin |
| 41 |
|
* |
| 42 |
|
* @param Zend_Acl $acl |
| 43 |
|
*/ |
| 44 |
|
public function __construct( Zend_Acl $acl ) |
| 45 |
|
{ |
| 46 |
2 |
$this->_acl = $acl; |
| 47 |
|
} |
| 48 |
|
|
| 49 |
|
/** |
| 50 |
|
* Gets the access control list |
| 51 |
|
* |
| 52 |
|
* @return Zend_Acl |
| 53 |
|
*/ |
| 54 |
|
public function getAcl() |
| 55 |
|
{ |
| 56 |
1 |
return $this->_acl; |
| 57 |
|
} |
| 58 |
|
|
| 59 |
|
/** |
| 60 |
|
* Loads an entity into the ACL if it's a {@link Zend_Acl_Resource_Interface} |
| 61 |
|
* |
| 62 |
|
* @param Xyster_Orm_Entity $entity |
| 63 |
|
*/ |
| 64 |
|
public function postLoad( Xyster_Orm_Entity $entity ) |
| 65 |
|
{ |
| 66 |
|
if ( $entity instanceof Zend_Acl_Resource_Interface |
| 67 |
1 |
&& !$this->_acl->has($entity) ) { |
| 68 |
1 |
$this->_acl->add($entity); |
| 69 |
1 |
} |
| 70 |
|
} |
| 71 |
|
} |