summaryrefslogtreecommitdiffstats
path: root/core/modules/rest/src/Plugin/ResourceBase.php
diff options
context:
space:
mode:
authorxjm2017-03-04 01:20:24 (GMT)
committerxjm2017-03-04 01:20:24 (GMT)
commit52e3eec616efab4d5201e30d085a09ba5c4817e6 (patch)
treed295cc8b862edc04018ba0e04ded752fd1a2f5c6 /core/modules/rest/src/Plugin/ResourceBase.php
parent3aba956a39a4852f42cad8483e4e6e307bedbd0e (diff)
Issue #2776975 by joelpittet, dawehner, tim.plunkett, xjm, pfrenssen: March 3, 2017: Convert core to array syntax coding standards for Drupal 8.3.x RC phase
Diffstat (limited to 'core/modules/rest/src/Plugin/ResourceBase.php')
-rw-r--r--core/modules/rest/src/Plugin/ResourceBase.php32
1 files changed, 16 insertions, 16 deletions
diff --git a/core/modules/rest/src/Plugin/ResourceBase.php b/core/modules/rest/src/Plugin/ResourceBase.php
index 93684db..3062aa2 100644
--- a/core/modules/rest/src/Plugin/ResourceBase.php
+++ b/core/modules/rest/src/Plugin/ResourceBase.php
@@ -31,7 +31,7 @@ abstract class ResourceBase extends PluginBase implements ContainerFactoryPlugin
*
* @var array
*/
- protected $serializerFormats = array();
+ protected $serializerFormats = [];
/**
* A logger instance.
@@ -81,13 +81,13 @@ abstract class ResourceBase extends PluginBase implements ContainerFactoryPlugin
* resource".
*/
public function permissions() {
- $permissions = array();
+ $permissions = [];
$definition = $this->getPluginDefinition();
foreach ($this->availableMethods() as $method) {
$lowered_method = strtolower($method);
- $permissions["restful $lowered_method $this->pluginId"] = array(
- 'title' => $this->t('Access @method on %label resource', array('@method' => $method, '%label' => $definition['label'])),
- );
+ $permissions["restful $lowered_method $this->pluginId"] = [
+ 'title' => $this->t('Access @method on %label resource', ['@method' => $method, '%label' => $definition['label']]),
+ ];
}
return $permissions;
}
@@ -113,14 +113,14 @@ abstract class ResourceBase extends PluginBase implements ContainerFactoryPlugin
$route->setPath($create_path);
// Restrict the incoming HTTP Content-type header to the known
// serialization formats.
- $route->addRequirements(array('_content_type_format' => implode('|', $this->serializerFormats)));
+ $route->addRequirements(['_content_type_format' => implode('|', $this->serializerFormats)]);
$collection->add("$route_name.$method", $route);
break;
case 'PATCH':
// Restrict the incoming HTTP Content-type header to the known
// serialization formats.
- $route->addRequirements(array('_content_type_format' => implode('|', $this->serializerFormats)));
+ $route->addRequirements(['_content_type_format' => implode('|', $this->serializerFormats)]);
$collection->add("$route_name.$method", $route);
break;
@@ -131,7 +131,7 @@ abstract class ResourceBase extends PluginBase implements ContainerFactoryPlugin
foreach ($this->serializerFormats as $format_name) {
// Expose one route per available format.
$format_route = clone $route;
- $format_route->addRequirements(array('_format' => $format_name));
+ $format_route->addRequirements(['_format' => $format_name]);
$collection->add("$route_name.$method.$format_name", $format_route);
}
break;
@@ -155,7 +155,7 @@ abstract class ResourceBase extends PluginBase implements ContainerFactoryPlugin
* The list of allowed HTTP request method strings.
*/
protected function requestMethods() {
- return array(
+ return [
'HEAD',
'GET',
'POST',
@@ -165,7 +165,7 @@ abstract class ResourceBase extends PluginBase implements ContainerFactoryPlugin
'OPTIONS',
'CONNECT',
'PATCH',
- );
+ ];
}
/**
@@ -173,7 +173,7 @@ abstract class ResourceBase extends PluginBase implements ContainerFactoryPlugin
*/
public function availableMethods() {
$methods = $this->requestMethods();
- $available = array();
+ $available = [];
foreach ($methods as $method) {
// Only expose methods where the HTTP request method exists on the plugin.
if (method_exists($this, strtolower($method))) {
@@ -195,15 +195,15 @@ abstract class ResourceBase extends PluginBase implements ContainerFactoryPlugin
* The created base route.
*/
protected function getBaseRoute($canonical_path, $method) {
- return new Route($canonical_path, array(
+ return new Route($canonical_path, [
'_controller' => 'Drupal\rest\RequestHandler::handle',
- ),
+ ],
$this->getBaseRouteRequirements($method),
- array(),
+ [],
'',
- array(),
+ [],
// The HTTP method is a requirement for this route.
- array($method)
+ [$method]
);
}