diff --git a/core/modules/rest/src/Plugin/rest/resource/EntityResource.php b/core/modules/rest/src/Plugin/rest/resource/EntityResource.php index bf5c5f9..39f5d1a 100644 --- a/core/modules/rest/src/Plugin/rest/resource/EntityResource.php +++ b/core/modules/rest/src/Plugin/rest/resource/EntityResource.php @@ -111,7 +111,6 @@ public function post(EntityInterface $entity = NULL) { // 201 Created responses have an empty body. $url = $entity->urlInfo('canonical', ['absolute' => TRUE])->toString(TRUE); $response = new UncacheableResourceResponse(NULL, 201, ['Location' => $url->getGeneratedUrl()]); - //$response->addCacheableDependency($url); return $response; } catch (EntityStorageException $e) { diff --git a/core/modules/rest/src/Plugin/rest/resource/UserRegistrationResource.php b/core/modules/rest/src/Plugin/rest/resource/UserRegistrationResource.php index d12b0f0..732cdba 100644 --- a/core/modules/rest/src/Plugin/rest/resource/UserRegistrationResource.php +++ b/core/modules/rest/src/Plugin/rest/resource/UserRegistrationResource.php @@ -68,14 +68,14 @@ class UserRegistrationResource extends ResourceBase { * The available serialization formats. * @param LoggerInterface $logger * A logger instance. - * @param \Drupal\Core\Config\Config $user_settings + * @param \Drupal\Core\Config\ImmutableConfig $user_settings * A user settings config instance. * @param \Drupal\Core\Session\AccountInterface $current_user * A user settings config instance. * @param \Drupal\Core\Render\RendererInterface $renderer * The renderer. */ - public function __construct(array $configuration, $plugin_id, $plugin_definition, array $serializer_formats, LoggerInterface $logger, Config $user_settings, AccountInterface $current_user, RendererInterface $renderer) { + public function __construct(array $configuration, $plugin_id, $plugin_definition, array $serializer_formats, LoggerInterface $logger, ImmutableConfig $user_settings, AccountInterface $current_user, RendererInterface $renderer) { parent::__construct($configuration, $plugin_id, $plugin_definition, $serializer_formats, $logger); $this->userSettings = $user_settings; $this->currentUser = $current_user; @@ -104,7 +104,7 @@ public static function create(ContainerInterface $container, array $configuratio * @param \Drupal\user\UserInterface $account * The user account entity. * - * @return \Drupal\rest\ResourceResponse + * @return \Drupal\rest\UncacheableResourceResponse * The HTTP response object. * * @throws \Symfony\Component\HttpKernel\Exception\HttpException @@ -150,8 +150,8 @@ public function post(UserInterface $account = NULL) { $account->save(); // Send emails from a render context to add bubbleable_metadata to the // response. - $register = $this->userSettings->get('register'); - // No email verification is required. Activating the user. + $register = $this->userSettings->get('register'); + // No email verification is required. Activating the user. if ($register == 'visitors') { if (!$this->userSettings->get('verify_mail')) { // Notification will be sent if activated. @@ -168,7 +168,8 @@ public function post(UserInterface $account = NULL) { _user_mail_notify('register_pending_approval', $account); } - $response = new UncacheableResourceResponse(NULL, 201, ['Location' => 'user/' . $account->id()]); + $url = $account->urlInfo('canonical', ['absolute' => TRUE])->toString(TRUE); + $response = new UncacheableResourceResponse(NULL, 201, ['Location' => $url->getGeneratedUrl()]); return $response; } diff --git a/core/modules/rest/src/RequestHandler.php b/core/modules/rest/src/RequestHandler.php index 13620e7..f525985 100644 --- a/core/modules/rest/src/RequestHandler.php +++ b/core/modules/rest/src/RequestHandler.php @@ -60,11 +60,8 @@ public function handle(RouteMatchInterface $route_match, Request $request) { if (empty($method_settings['supported_formats']) || in_array($format, $method_settings['supported_formats'])) { $definition = $resource->getPluginDefinition(); $class = $definition['serialization_class']; - $context = array(); - $context['request_method'] = $method; - try { - $unserialized = $serializer->deserialize($received, $class, $format, $context); + $unserialized = $serializer->deserialize($received, $class, $format, array('request_method' => $method)); } catch (UnexpectedValueException $e) { $error['error'] = $e->getMessage(); diff --git a/core/modules/rest/src/ResourceResponseTrait.php b/core/modules/rest/src/ResourceResponseTrait.php index 74a19c8..0539df6 100644 --- a/core/modules/rest/src/ResourceResponseTrait.php +++ b/core/modules/rest/src/ResourceResponseTrait.php @@ -26,4 +26,5 @@ public function getResponseData() { return $this->responseData; } -} \ No newline at end of file + +}