@@ -28,6 +28,9 @@ discard block |
||
| 28 | 28 | */ |
| 29 | 29 | private $enforcer; |
| 30 | 30 | |
| 31 | + /** |
|
| 32 | + * @param Resource $resource |
|
| 33 | + */ |
|
| 31 | 34 | public function __construct(UserInterface $user, $resource, $route = null) |
| 32 | 35 | { |
| 33 | 36 | $this->user = $user; |
@@ -50,7 +53,7 @@ discard block |
||
| 50 | 53 | /** |
| 51 | 54 | * Get the current user instance |
| 52 | 55 | * |
| 53 | - * @return \Psecio\Invoke\InvokeUser instance |
|
| 56 | + * @return UserInterface instance |
|
| 54 | 57 | */ |
| 55 | 58 | public function getUser() |
| 56 | 59 | { |
@@ -80,7 +83,7 @@ discard block |
||
| 80 | 83 | /** |
| 81 | 84 | * Set the current route instance |
| 82 | 85 | * |
| 83 | - * @param \Psecio\Invoke\RouteContaine $route Instance |
|
| 86 | + * @param RouteContainer $route Instance |
|
| 84 | 87 | */ |
| 85 | 88 | public function setRoute(RouteContainer $route) |
| 86 | 89 | { |
@@ -92,7 +92,7 @@ |
||
| 92 | 92 | * |
| 93 | 93 | * @param \Psecio\Invoke\Enforcer $enforcer Enforcer object |
| 94 | 94 | */ |
| 95 | - public function setEnforcer(\Psecio\Invoke\Enforcer &$enforcer) |
|
| 95 | + public function setEnforcer(\Psecio\Invoke\Enforcer & $enforcer) |
|
| 96 | 96 | { |
| 97 | 97 | $this->enforcer = $enforcer; |
| 98 | 98 | } |
@@ -39,6 +39,7 @@ |
||
| 39 | 39 | /** |
| 40 | 40 | * Get the current configuration |
| 41 | 41 | * |
| 42 | + * @param string $name |
|
| 42 | 43 | * @return array Configuration set |
| 43 | 44 | */ |
| 44 | 45 | public function getConfig($name = null) |
@@ -4,79 +4,79 @@ |
||
| 4 | 4 | |
| 5 | 5 | class RouteContainer |
| 6 | 6 | { |
| 7 | - /** |
|
| 8 | - * Current route (match) instance |
|
| 9 | - * @var \Psecio\Invoke\MatchInstance |
|
| 10 | - */ |
|
| 11 | - private $route; |
|
| 7 | + /** |
|
| 8 | + * Current route (match) instance |
|
| 9 | + * @var \Psecio\Invoke\MatchInstance |
|
| 10 | + */ |
|
| 11 | + private $route; |
|
| 12 | 12 | |
| 13 | - /** |
|
| 14 | - * Current configuration |
|
| 15 | - * @var array |
|
| 16 | - */ |
|
| 17 | - private $config; |
|
| 13 | + /** |
|
| 14 | + * Current configuration |
|
| 15 | + * @var array |
|
| 16 | + */ |
|
| 17 | + private $config; |
|
| 18 | 18 | |
| 19 | - /** |
|
| 20 | - * Parameters found in route processing |
|
| 21 | - * @var array |
|
| 22 | - */ |
|
| 23 | - private $params = []; |
|
| 19 | + /** |
|
| 20 | + * Parameters found in route processing |
|
| 21 | + * @var array |
|
| 22 | + */ |
|
| 23 | + private $params = []; |
|
| 24 | 24 | |
| 25 | - /** |
|
| 26 | - * Initialize the container with the provided route and |
|
| 27 | - * configuration information |
|
| 28 | - * |
|
| 29 | - * @param string $route Route to provide to the match |
|
| 30 | - * @param array $config Route configuration |
|
| 31 | - */ |
|
| 32 | - public function __construct($route, array $config) |
|
| 33 | - { |
|
| 34 | - $this->route = \Psecio\Invoke\Match::create('route.regex', |
|
| 35 | - array('route' => $route)); |
|
| 36 | - $this->config = $config; |
|
| 37 | - } |
|
| 25 | + /** |
|
| 26 | + * Initialize the container with the provided route and |
|
| 27 | + * configuration information |
|
| 28 | + * |
|
| 29 | + * @param string $route Route to provide to the match |
|
| 30 | + * @param array $config Route configuration |
|
| 31 | + */ |
|
| 32 | + public function __construct($route, array $config) |
|
| 33 | + { |
|
| 34 | + $this->route = \Psecio\Invoke\Match::create('route.regex', |
|
| 35 | + array('route' => $route)); |
|
| 36 | + $this->config = $config; |
|
| 37 | + } |
|
| 38 | 38 | |
| 39 | - /** |
|
| 40 | - * Get the current configuration |
|
| 41 | - * |
|
| 42 | - * @return array Configuration set |
|
| 43 | - */ |
|
| 44 | - public function getConfig($name = null) |
|
| 45 | - { |
|
| 46 | - if ($name !== null) { |
|
| 47 | - return (isset($this->config[$name])) ? $this->config[$name] : null; |
|
| 48 | - } else { |
|
| 49 | - return $this->config; |
|
| 50 | - } |
|
| 51 | - } |
|
| 39 | + /** |
|
| 40 | + * Get the current configuration |
|
| 41 | + * |
|
| 42 | + * @return array Configuration set |
|
| 43 | + */ |
|
| 44 | + public function getConfig($name = null) |
|
| 45 | + { |
|
| 46 | + if ($name !== null) { |
|
| 47 | + return (isset($this->config[$name])) ? $this->config[$name] : null; |
|
| 48 | + } else { |
|
| 49 | + return $this->config; |
|
| 50 | + } |
|
| 51 | + } |
|
| 52 | 52 | |
| 53 | - /** |
|
| 54 | - * Get the current route instance |
|
| 55 | - * |
|
| 56 | - * @return \Psecio\Invoke\MatchInstance |
|
| 57 | - */ |
|
| 58 | - public function getRoute() |
|
| 59 | - { |
|
| 60 | - return $this->route; |
|
| 61 | - } |
|
| 53 | + /** |
|
| 54 | + * Get the current route instance |
|
| 55 | + * |
|
| 56 | + * @return \Psecio\Invoke\MatchInstance |
|
| 57 | + */ |
|
| 58 | + public function getRoute() |
|
| 59 | + { |
|
| 60 | + return $this->route; |
|
| 61 | + } |
|
| 62 | 62 | |
| 63 | - /** |
|
| 64 | - * Set the parameters for the current route match |
|
| 65 | - * |
|
| 66 | - * @param array $params Parameter set |
|
| 67 | - */ |
|
| 68 | - public function setParams(array $params = array()) |
|
| 69 | - { |
|
| 70 | - $this->params = $params; |
|
| 71 | - } |
|
| 63 | + /** |
|
| 64 | + * Set the parameters for the current route match |
|
| 65 | + * |
|
| 66 | + * @param array $params Parameter set |
|
| 67 | + */ |
|
| 68 | + public function setParams(array $params = array()) |
|
| 69 | + { |
|
| 70 | + $this->params = $params; |
|
| 71 | + } |
|
| 72 | 72 | |
| 73 | - /** |
|
| 74 | - * Get the current parameter set |
|
| 75 | - * |
|
| 76 | - * @return array Parameter set |
|
| 77 | - */ |
|
| 78 | - public function getParams() |
|
| 79 | - { |
|
| 80 | - return $this->params; |
|
| 81 | - } |
|
| 73 | + /** |
|
| 74 | + * Get the current parameter set |
|
| 75 | + * |
|
| 76 | + * @return array Parameter set |
|
| 77 | + */ |
|
| 78 | + public function getParams() |
|
| 79 | + { |
|
| 80 | + return $this->params; |
|
| 81 | + } |
|
| 82 | 82 | } |
| 83 | 83 | \ No newline at end of file |
@@ -33,7 +33,7 @@ |
||
| 33 | 33 | { |
| 34 | 34 | $typeNs = "\\Psecio\\Invoke\\Match"; |
| 35 | 35 | foreach (explode('.', $type) as $part) { |
| 36 | - $typeNs .= "\\".ucwords($part); |
|
| 36 | + $typeNs .= "\\".ucwords($part); |
|
| 37 | 37 | } |
| 38 | 38 | return $typeNs; |
| 39 | 39 | } |
@@ -4,27 +4,27 @@ |
||
| 4 | 4 | |
| 5 | 5 | class Inherit extends \Psecio\Invoke\MatchInstance |
| 6 | 6 | { |
| 7 | - /** |
|
| 8 | - * Execute the check |
|
| 9 | - * |
|
| 10 | - * @param \Psecio\Invoke\Data $data Data object instance |
|
| 11 | - * @return boolean Result of evaluation |
|
| 12 | - */ |
|
| 13 | - public function evaluate($data) |
|
| 14 | - { |
|
| 15 | - $inherit = $data->route->getConfig('inherit'); |
|
| 7 | + /** |
|
| 8 | + * Execute the check |
|
| 9 | + * |
|
| 10 | + * @param \Psecio\Invoke\Data $data Data object instance |
|
| 11 | + * @return boolean Result of evaluation |
|
| 12 | + */ |
|
| 13 | + public function evaluate($data) |
|
| 14 | + { |
|
| 15 | + $inherit = $data->route->getConfig('inherit'); |
|
| 16 | 16 | |
| 17 | - if ($inherit !== null) { |
|
| 18 | - $routes = $data->getEnforcer()->getConfig(); |
|
| 17 | + if ($inherit !== null) { |
|
| 18 | + $routes = $data->getEnforcer()->getConfig(); |
|
| 19 | 19 | |
| 20 | - // Find the one to inherit from |
|
| 21 | - foreach ($routes as $route) { |
|
| 22 | - if ($route->getConfig('name') === $inherit) { |
|
| 23 | - $data->getEnforcer()->addMatch($route); |
|
| 24 | - return true; |
|
| 25 | - } |
|
| 26 | - } |
|
| 27 | - } |
|
| 28 | - return false; |
|
| 29 | - } |
|
| 20 | + // Find the one to inherit from |
|
| 21 | + foreach ($routes as $route) { |
|
| 22 | + if ($route->getConfig('name') === $inherit) { |
|
| 23 | + $data->getEnforcer()->addMatch($route); |
|
| 24 | + return true; |
|
| 25 | + } |
|
| 26 | + } |
|
| 27 | + } |
|
| 28 | + return false; |
|
| 29 | + } |
|
| 30 | 30 | } |
| 31 | 31 | \ No newline at end of file |
@@ -57,12 +57,12 @@ |
||
| 57 | 57 | public function load() |
| 58 | 58 | { |
| 59 | 59 | $yaml = new \Symfony\Component\Yaml\Parser(); |
| 60 | - $config = $yaml->parse(file_get_contents($this->path)); |
|
| 60 | + $config = $yaml->parse(file_get_contents($this->path)); |
|
| 61 | 61 | |
| 62 | - foreach ($config as $route => $setup) { |
|
| 63 | - $this->config[$route] = new \Psecio\Invoke\RouteContainer($route, $setup); |
|
| 64 | - } |
|
| 65 | - return $this->config; |
|
| 62 | + foreach ($config as $route => $setup) { |
|
| 63 | + $this->config[$route] = new \Psecio\Invoke\RouteContainer($route, $setup); |
|
| 64 | + } |
|
| 65 | + return $this->config; |
|
| 66 | 66 | } |
| 67 | 67 | |
| 68 | 68 | /** |
@@ -36,7 +36,7 @@ discard block |
||
| 36 | 36 | public function loadConfig($configPath) |
| 37 | 37 | { |
| 38 | 38 | $yaml = new \Symfony\Component\Yaml\Parser(); |
| 39 | - $config = $yaml->parse(file_get_contents($configPath)); |
|
| 39 | + $config = $yaml->parse(file_get_contents($configPath)); |
|
| 40 | 40 | |
| 41 | 41 | if (is_array($config) && !empty($config)) { |
| 42 | 42 | foreach ($config as $route => $setup) { |
@@ -44,7 +44,7 @@ discard block |
||
| 44 | 44 | } |
| 45 | 45 | } |
| 46 | 46 | |
| 47 | - return $this->config; |
|
| 47 | + return $this->config; |
|
| 48 | 48 | } |
| 49 | 49 | |
| 50 | 50 | /** |