http://phing.info/

Source Code Coverage

Designed for use with PHPUnit2, Xdebug and Phing.

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


Report generated at 2010-10-18T17:19:48-04:00