comparison core/modules/rest/tests/src/Functional/ResourceTestBase.php @ 17:129ea1e6d783

Update, including to Drupal core 8.6.10
author Chris Cannam
date Thu, 28 Feb 2019 13:21:36 +0000
parents c2387f117808
children
comparison
equal deleted inserted replaced
16:c2387f117808 17:129ea1e6d783
142 * @param string[] $formats 142 * @param string[] $formats
143 * The allowed formats for this resource. 143 * The allowed formats for this resource.
144 * @param string[] $authentication 144 * @param string[] $authentication
145 * The allowed authentication providers for this resource. 145 * The allowed authentication providers for this resource.
146 */ 146 */
147 protected function provisionResource($formats = [], $authentication = []) { 147 protected function provisionResource($formats = [], $authentication = [], array $methods = ['GET', 'POST', 'PATCH', 'DELETE']) {
148 $this->resourceConfigStorage->create([ 148 $this->resourceConfigStorage->create([
149 'id' => static::$resourceConfigId, 149 'id' => static::$resourceConfigId,
150 'granularity' => RestResourceConfigInterface::RESOURCE_GRANULARITY, 150 'granularity' => RestResourceConfigInterface::RESOURCE_GRANULARITY,
151 'configuration' => [ 151 'configuration' => [
152 'methods' => ['GET', 'POST', 'PATCH', 'DELETE'], 152 'methods' => $methods,
153 'formats' => $formats, 153 'formats' => $formats,
154 'authentication' => $authentication, 154 'authentication' => $authentication,
155 ], 155 ],
156 'status' => TRUE, 156 'status' => TRUE,
157 ])->save(); 157 ])->save();
479 } 479 }
480 } 480 }
481 return $request_options; 481 return $request_options;
482 } 482 }
483 483
484 /**
485 * Recursively sorts an array by key.
486 *
487 * @param array $array
488 * An array to sort.
489 *
490 * @return array
491 * The sorted array.
492 */
493 protected static function recursiveKSort(array &$array) {
494 // First, sort the main array.
495 ksort($array);
496
497 // Then check for child arrays.
498 foreach ($array as $key => &$value) {
499 if (is_array($value)) {
500 static::recursiveKSort($value);
501 }
502 }
503 }
504
484 } 505 }