Skip to content

Commit

Permalink
rename methods
Browse files Browse the repository at this point in the history
  • Loading branch information
taylorotwell committed Dec 7, 2016
1 parent b742e82 commit e91f04b
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 24 deletions.
30 changes: 12 additions & 18 deletions src/Illuminate/Routing/ResourceRegistrar.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,11 @@ class ResourceRegistrar
protected static $singularParameters = true;

/**
* Uri translations.
* The verbs used in the resource URIs.
*
* @var array
*/
protected static $uriTranslations = [
protected static $verbs = [
'create' => 'create',
'edit' => 'edit',
];
Expand Down Expand Up @@ -300,7 +300,7 @@ protected function addResourceIndex($name, $base, $controller, $options)
*/
protected function addResourceCreate($name, $base, $controller, $options)
{
$uri = $this->getResourceUri($name).'/'.static::$uriTranslations['create'];
$uri = $this->getResourceUri($name).'/'.static::$verbs['create'];

$action = $this->getResourceAction($name, $controller, 'create', $options);

Expand Down Expand Up @@ -354,7 +354,7 @@ protected function addResourceShow($name, $base, $controller, $options)
*/
protected function addResourceEdit($name, $base, $controller, $options)
{
$uri = $this->getResourceUri($name).'/{'.$base.'}/'.static::$uriTranslations['edit'];
$uri = $this->getResourceUri($name).'/{'.$base.'}/'.static::$verbs['edit'];

$action = $this->getResourceAction($name, $controller, 'edit', $options);

Expand Down Expand Up @@ -430,23 +430,17 @@ public static function setParameters(array $parameters = [])
}

/**
* Get the uri translations.
* Get or set the action verbs used in the resource URIs.
*
* @param array $verbs
* @return array
*/
public static function getUriTranslations()
public static function verbs(array $verbs = [])
{
return static::$uriTranslations;
}

/**
* Set the uri translations.
*
* @param array $translations
* @return void
*/
public static function setUriTranslations(array $translations = [])
{
static::$uriTranslations = array_merge(static::$uriTranslations, $translations);
if (empty($verbs)) {
return static::$verbs;
} else {
static::$verbs = array_merge(static::$verbs, $verbs);
}
}
}
10 changes: 5 additions & 5 deletions src/Illuminate/Routing/Router.php
Original file line number Diff line number Diff line change
Expand Up @@ -248,14 +248,14 @@ public function resourceParameters(array $parameters = [])
}

/**
* Set the uri translations.
* Get or set the verbs used in the resource URIs.
*
* @param array $translations
* @return void
* @param array $verbs
* @return array|null
*/
public function uriTranslations(array $translations = [])
public function resourceVerbs(array $verbs = [])
{
ResourceRegistrar::setUriTranslations($translations);
return ResourceRegistrar::verbs($verbs);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion tests/Routing/RoutingRouteTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -922,7 +922,7 @@ public function testResourceRouting()
$this->assertEquals('foo-bars/{foo_bar}', $routes[0]->getUri());
$this->assertEquals('prefix.foo-bars.show', $routes[0]->getName());

ResourceRegistrar::setUriTranslations([
ResourceRegistrar::verbs([
'create' => 'ajouter',
'edit' => 'modifier',
]);
Expand Down

0 comments on commit e91f04b

Please sign in to comment.