diff --git a/core/modules/file/src/Plugin/Field/FieldType/FileUriItem.php b/core/modules/file/src/Plugin/Field/FieldType/FileUriItem.php
index 2c80a9383a..84f09406f3 100644
--- a/core/modules/file/src/Plugin/Field/FieldType/FileUriItem.php
+++ b/core/modules/file/src/Plugin/Field/FieldType/FileUriItem.php
@@ -28,7 +28,7 @@ public static function propertyDefinitions(FieldStorageDefinitionInterface $fiel
$properties = parent::propertyDefinitions($field_definition);
$properties['url'] = DataDefinition::create('uri')
- ->setLabel(t('Full URL'))
+ ->setLabel(t('Root-relative file URL'))
->setSetting('case_sensitive', $field_definition->getSetting('case_sensitive'))
->setComputed(TRUE)
->setInternal(FALSE)
diff --git a/core/modules/hal/hal.install b/core/modules/hal/hal.install
index 77e932f74f..0dc3fd566d 100644
--- a/core/modules/hal/hal.install
+++ b/core/modules/hal/hal.install
@@ -38,8 +38,8 @@ function hal_update_8301() {
function hal_update_8501() {
$config_factory = \Drupal::configFactory();
$config_factory->getEditable('hal.settings')
- ->set('bc_file_uri_as_url_normalizer', FALSE)
+ ->set('bc_file_uri_as_url_normalizer', TRUE)
->save(TRUE);
- return t('The REST API will no longer return the full URL for file entity URI values. It will return the URI value itself, with an additional URL property providing a root relative file path. If your site depends on these value being strings, read the change record to learn how to enable the BC mode.');
+ return t('The REST API will no longer return the full URL for file entity URI values for HAL+JSON responses. It will return the URI value itself, with an additional URL property providing a root relative file path. If your site depends on these value being strings, read the change record to learn how to enable the BC mode.');
}
diff --git a/core/modules/hal/src/Normalizer/FileEntityNormalizer.php b/core/modules/hal/src/Normalizer/FileEntityNormalizer.php
index 31a0f53f0e..1f9bd7e447 100644
--- a/core/modules/hal/src/Normalizer/FileEntityNormalizer.php
+++ b/core/modules/hal/src/Normalizer/FileEntityNormalizer.php
@@ -30,11 +30,11 @@ class FileEntityNormalizer extends ContentEntityNormalizer {
protected $httpClient;
/**
- * The hal config.
+ * The hal settings config.
*
* @var \Drupal\Core\Config\Config
*/
- protected $config;
+ protected $halSettings;
/**
* Constructs a FileEntityNormalizer object.
@@ -47,12 +47,14 @@ class FileEntityNormalizer extends ContentEntityNormalizer {
* The hypermedia link manager.
* @param \Drupal\Core\Extension\ModuleHandlerInterface $module_handler
* The module handler.
+ * @param \Drupal\Core\Config\ConfigFactoryInterface $config_factory
+ * The config factory.
*/
- public function __construct(EntityManagerInterface $entity_manager, ClientInterface $http_client, LinkManagerInterface $link_manager, ModuleHandlerInterface $module_handler, ConfigFactoryInterface $config_facotry) {
+ public function __construct(EntityManagerInterface $entity_manager, ClientInterface $http_client, LinkManagerInterface $link_manager, ModuleHandlerInterface $module_handler, ConfigFactoryInterface $config_factory) {
parent::__construct($link_manager, $entity_manager, $module_handler);
$this->httpClient = $http_client;
- $this->config = $config_facotry->get('hal.settings');
+ $this->halSettings = $config_factory->get('hal.settings');
}
/**
@@ -61,7 +63,9 @@ public function __construct(EntityManagerInterface $entity_manager, ClientInterf
public function normalize($entity, $format = NULL, array $context = []) {
$data = parent::normalize($entity, $format, $context);
- if ($this->config->get('bc_file_uri_as_url_normalizer')) {
+ $this->addCacheableDependency($this->halSettings);
+
+ if ($this->halSettings->get('bc_file_uri_as_url_normalizer')) {
// Replace the file url with a full url for the file.
$data['uri'][0]['value'] = $this->getEntityUri($entity);
}