Skip to content

Commit

Permalink
Rename resource() to resources().
Browse files Browse the repository at this point in the history
Using the plural form makes more sense as the table names are plural and
controllers are plural too.
  • Loading branch information
markstory committed Jun 26, 2014
1 parent 4d9e65e commit 1b2fc58
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
10 changes: 5 additions & 5 deletions src/Routing/ScopedRouteCollection.php
Expand Up @@ -189,7 +189,7 @@ public function get($name) {
*
* {{{
* Router::plugin('Comments', function ($routes) {
* $routes->resource('Comments');
* $routes->resources('Comments');
* });
* }}}
*
Expand All @@ -201,7 +201,7 @@ public function get($name) {
*
* {{{
* Router::prefix('admin', function ($routes) {
* $routes->resource('Articles');
* $routes->resources('Articles');
* });
* }}}
*
Expand All @@ -211,8 +211,8 @@ public function get($name) {
* You can create nested resources by passing a callback in:
*
* {{{
* $routes->resource('Articles', function($routes) {
* $routes->resource('Comments');
* $routes->resources('Articles', function($routes) {
* $routes->resources('Comments');
* });
* }}}
*
Expand All @@ -229,7 +229,7 @@ public function get($name) {
* scopes inherit the existing path and 'id' parameter.
* @return array Array of mapped resources
*/
public function resource($name, $options = [], $callback = null) {
public function resources($name, $options = [], $callback = null) {
if (is_callable($options) && $callback === null) {
$callback = $options;
$options = [];
Expand Down
10 changes: 5 additions & 5 deletions tests/TestCase/Routing/ScopedRouteCollectionTest.php
Expand Up @@ -319,9 +319,9 @@ public function testMatchPlugin() {
*
* @return void
*/
public function testResource() {
public function testResources() {
$routes = new ScopedRouteCollection('/api', ['prefix' => 'api']);
$routes->resource('Articles', ['_ext' => 'json']);
$routes->resources('Articles', ['_ext' => 'json']);

$all = $routes->routes();
$this->assertCount(6, $all);
Expand All @@ -336,13 +336,13 @@ public function testResource() {
*
* @return void
*/
public function testResourceNested() {
public function testResourcesNested() {
$routes = new ScopedRouteCollection('/api', ['prefix' => 'api']);
$routes->resource('Articles', function($routes) {
$routes->resources('Articles', function($routes) {
$this->assertEquals('/api/articles/', $routes->path());
$this->assertEquals(['prefix' => 'api'], $routes->params());

$routes->resource('Comments');
$routes->resources('Comments');
$route = $routes->routes()[0];
$this->assertEquals('/api/articles/:article_id/comments', $route->template);
});
Expand Down

0 comments on commit 1b2fc58

Please sign in to comment.