| 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_Acl |
| 12 |
|
* @copyright Copyright (c) 2007-2008 Irrational Logic (http://irrationallogic.net) |
| 13 |
|
* @license http://www.opensource.org/licenses/bsd-license.php New BSD License |
| 14 |
|
* @version $Id: Resource.php 202 2008-01-20 16:20:09Z doublecompile $ |
| 15 |
|
*/ |
| 16 |
|
/** |
| 17 |
|
* Zend_Acl_Resource_Interface |
| 18 |
|
*/ |
| 19 |
1 |
require_once 'Zend/Acl/Resource/Interface.php'; |
| 20 |
|
/** |
| 21 |
|
* An ACL resource to represent an MVC dispatch location |
| 22 |
|
* |
| 23 |
|
* @category Xyster |
| 24 |
|
* @package Xyster_Controller |
| 25 |
|
* @copyright Copyright (c) 2007-2008 Irrational Logic (http://irrationallogic.net) |
| 26 |
|
* @license http://www.opensource.org/licenses/bsd-license.php New BSD License |
| 27 |
|
*/ |
| 28 |
|
class Xyster_Controller_Request_Resource implements Zend_Acl_Resource_Interface |
| 29 |
|
{ |
| 30 |
|
/** |
| 31 |
|
* @var string |
| 32 |
|
*/ |
| 33 |
|
protected $_module; |
| 34 |
|
|
| 35 |
|
/** |
| 36 |
|
* @var string |
| 37 |
|
*/ |
| 38 |
|
protected $_controller; |
| 39 |
|
|
| 40 |
|
/** |
| 41 |
|
* @var string |
| 42 |
|
*/ |
| 43 |
|
protected $_action; |
| 44 |
|
|
| 45 |
|
/** |
| 46 |
|
* Creates a new request resource |
| 47 |
|
* |
| 48 |
|
* @param string $module |
| 49 |
|
* @param string $controller |
| 50 |
|
* @param string $action |
| 51 |
|
*/ |
| 52 |
|
public function __construct( $module, $controller=null, $action=null ) |
| 53 |
|
{ |
| 54 |
9 |
$this->_module = $module; |
| 55 |
9 |
$this->_controller = $controller; |
| 56 |
9 |
$this->_action = $action; |
| 57 |
|
} |
| 58 |
|
|
| 59 |
|
/** |
| 60 |
|
* Creates a new request resource based on the values in a request |
| 61 |
|
* |
| 62 |
|
* @param Zend_Controller_Request_Abstract $request |
| 63 |
|
* @return Xyster_Controller_Request_Resource |
| 64 |
|
*/ |
| 65 |
|
static public function create( Zend_Controller_Request_Abstract $request ) |
| 66 |
|
{ |
| 67 |
4 |
return new self($request->getModuleName(), |
| 68 |
4 |
$request->getControllerName(), $request->getActionName()); |
| 69 |
|
} |
| 70 |
|
|
| 71 |
|
/** |
| 72 |
|
* Returns the action |
| 73 |
|
* |
| 74 |
|
* @return string |
| 75 |
|
*/ |
| 76 |
|
public function getAction() |
| 77 |
|
{ |
| 78 |
1 |
return $this->_action; |
| 79 |
|
} |
| 80 |
|
|
| 81 |
|
/** |
| 82 |
|
* Returns the controller |
| 83 |
|
* |
| 84 |
|
* @return string |
| 85 |
|
*/ |
| 86 |
|
public function getController() |
| 87 |
|
{ |
| 88 |
1 |
return $this->_controller; |
| 89 |
|
} |
| 90 |
|
|
| 91 |
|
/** |
| 92 |
|
* Returns the module |
| 93 |
|
* |
| 94 |
|
* @return string |
| 95 |
|
*/ |
| 96 |
|
public function getModule() |
| 97 |
|
{ |
| 98 |
1 |
return $this->_module; |
| 99 |
|
} |
| 100 |
|
|
| 101 |
|
/** |
| 102 |
|
* Returns the string identifier of the Resource |
| 103 |
|
* |
| 104 |
|
* @return string |
| 105 |
|
*/ |
| 106 |
|
public function getResourceId() |
| 107 |
|
{ |
| 108 |
7 |
$resource = 'MVC:' . $this->_module . '/'; |
| 109 |
7 |
if ( $this->_controller ) { |
| 110 |
7 |
$resource .= $this->_controller . '/'; |
| 111 |
7 |
} |
| 112 |
7 |
if ( $this->_controller && $this->_action ) { |
| 113 |
7 |
$resource .= $this->_action; |
| 114 |
7 |
} |
| 115 |
|
|
| 116 |
7 |
return $resource; |
| 117 |
|
} |
| 118 |
|
|
| 119 |
|
/** |
| 120 |
|
* Returns the string identifier of the Resource |
| 121 |
|
* |
| 122 |
|
* @return string |
| 123 |
|
*/ |
| 124 |
|
public function __toString() |
| 125 |
|
{ |
| 126 |
1 |
return $this->getResourceId(); |
| 127 |
|
} |
| 128 |
|
} |