Skip to content

Commit d68e37d

Browse files
committed
Parse scopes set on groups so they are available as an array.
Signed-off-by: Jason Lewis <[email protected]>
1 parent e99c126 commit d68e37d

File tree

3 files changed

+29
-0
lines changed

3 files changed

+29
-0
lines changed

changes.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
- Made the trace readable by exploding on the EOL character.
66
- API filters are now applied before any other filters to ensure they are run first.
77
- Request and response instances are correctly set on the formatter for exception responses.
8+
- Scopes set on groups are now parsed correctly.
89

910
### v0.8.2
1011

src/Routing/Route.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,16 @@ protected function parseAction($action)
5050
return $action;
5151
}
5252

53+
/**
54+
* {@inheritDoc}
55+
*/
56+
public function setAction(array $action)
57+
{
58+
$action = static::parseAction($action);
59+
60+
return parent::setAction($action);
61+
}
62+
5363
/**
5464
* Determine if the route is protected.
5565
*

tests/Routing/RouterTest.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -437,4 +437,22 @@ public function testRouterThrowsExceptionWhenInvalidAcceptHeaderWithStrict()
437437
$this->router->setStrict(true);
438438
$this->router->dispatch(Request::create('foo', 'GET'));
439439
}
440+
441+
public function testRouterParsesScopesFromStringsToArrays()
442+
{
443+
$this->router->api(['version' => 'v1'], function () {
444+
$this->router->group(['scopes' => 'foo'], function () {
445+
$this->router->get('foo', function () {
446+
return 'bar';
447+
});
448+
});
449+
450+
$this->router->get('bar', ['scopes' => 'bar', function () {
451+
return 'baz';
452+
}]);
453+
});
454+
455+
$this->assertEquals(['foo'], $this->router->getApiGroups()->getByVersion('v1')->getRoutes()[0]->scopes());
456+
$this->assertEquals(['bar'], $this->router->getApiGroups()->getByVersion('v1')->getRoutes()[1]->scopes());
457+
}
440458
}

0 commit comments

Comments
 (0)