Permalink
Browse files

Removed the last of the code within lib that relies upon Utils/Opt

  • Loading branch information...
1 parent 8bcd96c commit 5c37f4761494ea21e1a0de10127e6d9e0fbed7ce @trq trq committed Aug 2, 2012
@@ -84,19 +84,15 @@
/**
* Instantiate this route
*
- * @param array $options An array of Proem\Api\Util\Opt\Option objects
+ * $options = ['rule', 'targets', 'filters', 'method', 'callback'];
+ *
+ * @param array $options
*/
public function __construct(array $options)
{
- $this->options = $this->setOptions([
- 'rule' => (new Option)->type('string')->required(),
- 'targets' => (new Option([]))->type('array'),
- 'filters' => (new Option([]))->type('array'),
- 'method' => (new Option(null))->type('string'),
- 'callback' => (new Option)->type('callable')
- ], $options);
-
- if (is_callable($this->options->callback)) {
+ $this->options = $options;
+
+ if (isset($this->options['callback']) && is_callable($this->options['callback'])) {
$this->hasCallback = true;
}
@@ -154,7 +150,7 @@ public function getPayload()
*/
public function call(Request $request)
{
- (new Callback($this->options->callback, $request))->call();
+ (new Callback($this->options['callback'], $request))->call();
}
/**
@@ -109,14 +109,14 @@ public function __construct(array $options) {
*/
public function process(Request $request)
{
- if (!$this->options->rule) {
+ if (!isset($this->options['rule'])) {
return false;
}
- $rule = $this->options->rule;
- $target = $this->options->targets;
- $custom_filters = $this->options->filters;
- $method = $this->options->method ?: 'GET';
+ $rule = $this->options['rule'];
+ $target = isset($this->options['targets']) ? $this->options['targets'] : [];
+ $custom_filters = isset($this->options['filters']) ? $this->options['filters'] : [];
+ $method = isset($this->options['method']) ? $this->options['method'] : 'GET';
$default_tokens = $this->default_tokens;
$default_filters = $this->default_filters;
@@ -41,18 +41,20 @@ class StaticRoute extends Generic
{
public function process(Request $request)
{
- if (!$this->options->rule) {
+ if (!isset($this->options['rule'])) {
return false;
}
- if (!isset($this->options->targets['module']) || !isset($this->options->targets['controller']) || !isset($this->options->targets['action'])) {
+ $method = isset($this->options['method']) ? $this->options['method'] : 'GET';
+
+ if (!isset($this->options['targets']) || !isset($this->options['targets']['module']) || !isset($this->options['targets']['controller']) || !isset($this->options['targets']['action'])) {
return false;
}
- if ($request->getRequestUri() == $this->options->rule && $request->getMethod() == ($this->options->method ?: 'GET')) {
- $this->getPayload()->set('module', $this->options->targets['module']);
- $this->getPayload()->set('controller', $this->options->targets['controller']);
- $this->getPayload()->set('action', $this->options->targets['action']);
+ if ($request->getRequestUri() == $this->options['rule'] && $request->getMethod() == $method) {
+ $this->getPayload()->set('module', $this->options['targets']['module']);
+ $this->getPayload()->set('controller', $this->options['targets']['controller']);
+ $this->getPayload()->set('action', $this->options['targets']['action']);
$this->setMatch();
$this->getPayload()->set('request', $request);

0 comments on commit 5c37f47

Please sign in to comment.