Commit 55a4f988 authored by catch's avatar catch

Issue #2854830 by Wim Leers: Move rest/serialization module's "link manager" services to HAL module

parent 7562fb24
# Set the domain for Serialization type and relation links.
# Set the domain for HAL type and relation links.
# If left blank, the site's domain will be used.
link_domain: ~
# Schema for the configuration files of the Serialization module.
serialization.settings:
# Schema for the configuration files of the HAL module.
hal.settings:
type: config_object
label: 'Serialization settings'
label: 'HAL settings'
mapping:
link_domain:
type: string
......
......@@ -2,7 +2,7 @@
/**
* @file
* Describes hooks provided by the Serialization module.
* Describes hooks provided by the HAL module.
*/
/**
......@@ -11,7 +11,7 @@
*/
/**
* Alter the serialization type URI.
* Alter the HAL type URI.
*
* Modules may wish to alter the type URI generated for a resource based on the
* context of the serializer/normalizer operation.
......@@ -26,16 +26,16 @@
* @see \Symfony\Component\Serializer\NormalizerInterface::normalize()
* @see \Symfony\Component\Serializer\DenormalizerInterface::denormalize()
*/
function hook_serialization_type_uri_alter(&$uri, $context = array()) {
function hook_hal_type_uri_alter(&$uri, $context = array()) {
if ($context['mymodule'] == TRUE) {
$base = \Drupal::config('serialization.settings')->get('link_domain');
$base = \Drupal::config('hal.settings')->get('link_domain');
$uri = str_replace($base, 'http://mymodule.domain', $uri);
}
}
/**
* Alter the serialization relation URI.
* Alter the HAL relation URI.
*
* Modules may wish to alter the relation URI generated for a resource based on
* the context of the serializer/normalizer operation.
......@@ -50,9 +50,9 @@ function hook_serialization_type_uri_alter(&$uri, $context = array()) {
* @see \Symfony\Component\Serializer\NormalizerInterface::normalize()
* @see \Symfony\Component\Serializer\DenormalizerInterface::denormalize()
*/
function hook_serialization_relation_uri_alter(&$uri, $context = array()) {
function hook_hal_relation_uri_alter(&$uri, $context = array()) {
if ($context['mymodule'] == TRUE) {
$base = \Drupal::config('serialization.settings')->get('link_domain');
$base = \Drupal::config('hal.settings')->get('link_domain');
$uri = str_replace($base, 'http://mymodule.domain', $uri);
}
}
......
<?php
/**
* @file
* Update functions for the HAL module.
*/
/**
* @defgroup updates-8.2.x-to-8.3.x Updates from 8.2.x to 8.3.x
* @{
* Update functions from 8.2.x to 8.3.x.
*/
/**
* Move 'link_domain' from 'rest.settings' to 'hal.settings'.
*/
function hal_update_8301() {
$config_factory = \Drupal::configFactory();
// The default value for the 'link_domain' key is `~`, which is the YAML
// equivalent of PHP's `NULL`. If the REST module is not installed, this is
// the value we will store in 'hal.settings'.
$link_domain = NULL;
// But if the REST module was installed, we migrate its 'link_domain' setting,
// because we are actually moving that setting from 'rest.settings' to
// 'hal.settings'.
$rest_settings = $config_factory->getEditable('rest.settings');
if ($rest_settings->getRawData() !== []) {
$link_domain = $rest_settings->get('link_domain');
// Remove the 'link_domain' setting from 'rest.settings'.
$rest_settings->clear('link_domain')
->save();
}
$hal_settings = $config_factory->getEditable('hal.settings');
$hal_settings->set('link_domain', $link_domain);
$hal_settings->save(TRUE);
}
/**
* @} End of "defgroup updates-8.2.x-to-8.3.x".
*/
services:
serializer.normalizer.entity_reference_item.hal:
class: Drupal\hal\Normalizer\EntityReferenceItemNormalizer
arguments: ['@serialization.link_manager', '@serializer.entity_resolver']
arguments: ['@hal.link_manager', '@serializer.entity_resolver']
tags:
- { name: normalizer, priority: 10 }
serializer.normalizer.field_item.hal:
......@@ -16,13 +16,24 @@ services:
class: Drupal\hal\Normalizer\FileEntityNormalizer
tags:
- { name: normalizer, priority: 20 }
arguments: ['@entity.manager', '@http_client', '@serialization.link_manager', '@module_handler']
arguments: ['@entity.manager', '@http_client', '@hal.link_manager', '@module_handler']
serializer.normalizer.entity.hal:
class: Drupal\hal\Normalizer\ContentEntityNormalizer
arguments: ['@serialization.link_manager', '@entity.manager', '@module_handler']
arguments: ['@hal.link_manager', '@entity.manager', '@module_handler']
tags:
- { name: normalizer, priority: 10 }
serializer.encoder.hal:
class: Drupal\hal\Encoder\JsonEncoder
tags:
- { name: encoder, priority: 10, format: hal_json }
# Link managers.
hal.link_manager:
class: Drupal\hal\LinkManager\LinkManager
arguments: ['@hal.link_manager.type', '@hal.link_manager.relation']
hal.link_manager.type:
class: Drupal\hal\LinkManager\TypeLinkManager
arguments: ['@cache.default', '@module_handler', '@config.factory', '@request_stack', '@entity_type.bundle.info']
hal.link_manager.relation:
class: Drupal\hal\LinkManager\RelationLinkManager
arguments: ['@cache.default', '@entity.manager', '@module_handler', '@config.factory', '@request_stack']
<?php
namespace Drupal\serialization\LinkManager;
namespace Drupal\hal\LinkManager;
/**
* Defines an interface for a link manager with a configurable domain.
......
<?php
namespace Drupal\serialization\LinkManager;
namespace Drupal\hal\LinkManager;
class LinkManager implements LinkManagerInterface {
/**
* The type link manager.
*
* @var \Drupal\serialization\LinkManager\TypeLinkManagerInterface
* @var \Drupal\hal\LinkManager\TypeLinkManagerInterface
*/
protected $typeLinkManager;
/**
* The relation link manager.
*
* @var \Drupal\serialization\LinkManager\RelationLinkManagerInterface
* @var \Drupal\hal\LinkManager\RelationLinkManagerInterface
*/
protected $relationLinkManager;
/**
* Constructor.
*
* @param \Drupal\serialization\LinkManager\TypeLinkManagerInterface $type_link_manager
* @param \Drupal\hal\LinkManager\TypeLinkManagerInterface $type_link_manager
* Manager for handling bundle URIs.
* @param \Drupal\serialization\LinkManager\RelationLinkManagerInterface $relation_link_manager
* @param \Drupal\hal\LinkManager\RelationLinkManagerInterface $relation_link_manager
* Manager for handling bundle URIs.
*/
public function __construct(TypeLinkManagerInterface $type_link_manager, RelationLinkManagerInterface $relation_link_manager) {
......
<?php
namespace Drupal\serialization\LinkManager;
namespace Drupal\hal\LinkManager;
/**
* Defines an abstract base-class for Serialization link manager objects.
* Defines an abstract base-class for HAL link manager objects.
*/
abstract class LinkManagerBase {
......@@ -44,7 +44,7 @@ public function setLinkDomain($domain) {
*/
protected function getLinkDomain() {
if (empty($this->linkDomain)) {
if ($domain = $this->configFactory->get('serialization.settings')->get('link_domain')) {
if ($domain = $this->configFactory->get('hal.settings')->get('link_domain')) {
$this->linkDomain = rtrim($domain, '/');
}
else {
......
<?php
namespace Drupal\serialization\LinkManager;
namespace Drupal\hal\LinkManager;
/**
* Interface implemented by link managers.
......
<?php
namespace Drupal\serialization\LinkManager;
namespace Drupal\hal\LinkManager;
use Drupal\Core\Cache\Cache;
use Drupal\Core\Cache\CacheBackendInterface;
......@@ -69,7 +69,7 @@ public function getRelationUri($entity_type, $bundle, $field_name, $context = ar
// different (e.g., include a language prefix), then the module must also
// override the RelationLinkManager class/service to return the desired URL.
$uri = $this->getLinkDomain() . "/rest/relation/$entity_type/$bundle/$field_name";
$this->moduleHandler->alter('serialization_relation_uri', $uri, $context);
$this->moduleHandler->alter('hal_relation_uri', $uri, $context);
// @deprecated in Drupal 8.3.x and will be removed before Drupal 9.0.0. This
// hook is invoked to maintain backwards compatibility
$this->moduleHandler->alter('rest_relation_uri', $uri, $context);
......@@ -104,7 +104,7 @@ public function getRelationInternalIds($relation_uri, $context = array()) {
* by corresponding relation URI.
*/
protected function getRelations($context = array()) {
$cid = 'serialization:links:relations';
$cid = 'hal:links:relations';
$cache = $this->cache->get($cid);
if (!$cache) {
$this->writeCache($context);
......@@ -138,7 +138,7 @@ protected function writeCache($context = array()) {
}
// These URIs only change when field info changes, so cache it permanently
// and only clear it when the fields cache is cleared.
$this->cache->set('serialization:links:relations', $data, Cache::PERMANENT, array('entity_field_info'));
$this->cache->set('hal:links:relations', $data, Cache::PERMANENT, array('entity_field_info'));
}
}
<?php
namespace Drupal\serialization\LinkManager;
namespace Drupal\hal\LinkManager;
interface RelationLinkManagerInterface extends ConfigurableLinkManagerInterface {
......
<?php
namespace Drupal\serialization\LinkManager;
namespace Drupal\hal\LinkManager;
use Drupal\Core\Cache\Cache;
use Drupal\Core\Cache\CacheBackendInterface;
......@@ -70,7 +70,7 @@ public function getTypeUri($entity_type, $bundle, $context = array()) {
// (e.g., include a language prefix), then the module must also override the
// TypeLinkManager class/service to return the desired URL.
$uri = $this->getLinkDomain() . "/rest/type/$entity_type/$bundle";
$this->moduleHandler->alter('serialization_type_uri', $uri, $context);
$this->moduleHandler->alter('hal_type_uri', $uri, $context);
// @deprecated in Drupal 8.3.x and will be removed before Drupal 9.0.0. This
// hook is invoked to maintain backwards compatibility
$this->moduleHandler->alter('rest_type_uri', $uri, $context);
......@@ -99,7 +99,7 @@ public function getTypeInternalIds($type_uri, $context = array()) {
* corresponding type URI.
*/
protected function getTypes($context = array()) {
$cid = 'serialization:links:types';
$cid = 'hal:links:types';
$cache = $this->cache->get($cid);
if (!$cache) {
$data = $this->writeCache($context);
......@@ -143,7 +143,7 @@ protected function writeCache($context = array()) {
}
// These URIs only change when entity info changes, so cache it permanently
// and only clear it when entity_info is cleared.
$this->cache->set('serialization:links:types', $data, Cache::PERMANENT, array('entity_types'));
$this->cache->set('hal:links:types', $data, Cache::PERMANENT, array('entity_types'));
return $data;
}
......
<?php
namespace Drupal\serialization\LinkManager;
namespace Drupal\hal\LinkManager;
interface TypeLinkManagerInterface extends ConfigurableLinkManagerInterface {
......
......@@ -6,7 +6,7 @@
use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\Entity\EntityManagerInterface;
use Drupal\Core\Extension\ModuleHandlerInterface;
use Drupal\serialization\LinkManager\LinkManagerInterface;
use Drupal\hal\LinkManager\LinkManagerInterface;
use Drupal\serialization\Normalizer\FieldableEntityNormalizerTrait;
use Symfony\Component\Serializer\Exception\UnexpectedValueException;
......@@ -27,7 +27,7 @@ class ContentEntityNormalizer extends NormalizerBase {
/**
* The hypermedia link manager.
*
* @var \Drupal\serialization\LinkManager\LinkManagerInterface
* @var \Drupal\hal\LinkManager\LinkManagerInterface
*/
protected $linkManager;
......@@ -41,7 +41,7 @@ class ContentEntityNormalizer extends NormalizerBase {
/**
* Constructs an ContentEntityNormalizer object.
*
* @param \Drupal\serialization\LinkManager\LinkManagerInterface $link_manager
* @param \Drupal\hal\LinkManager\LinkManagerInterface $link_manager
* The hypermedia link manager.
*/
public function __construct(LinkManagerInterface $link_manager, EntityManagerInterface $entity_manager, ModuleHandlerInterface $module_handler) {
......
......@@ -3,7 +3,7 @@
namespace Drupal\hal\Normalizer;
use Drupal\Core\Entity\FieldableEntityInterface;
use Drupal\serialization\LinkManager\LinkManagerInterface;
use Drupal\hal\LinkManager\LinkManagerInterface;
use Drupal\serialization\EntityResolver\EntityResolverInterface;
use Drupal\serialization\EntityResolver\UuidReferenceInterface;
......@@ -22,7 +22,7 @@ class EntityReferenceItemNormalizer extends FieldItemNormalizer implements UuidR
/**
* The hypermedia link manager.
*
* @var \Drupal\serialization\LinkManager\LinkManagerInterface
* @var \Drupal\hal\LinkManager\LinkManagerInterface
*/
protected $linkManager;
......@@ -36,7 +36,7 @@ class EntityReferenceItemNormalizer extends FieldItemNormalizer implements UuidR
/**
* Constructs an EntityReferenceItemNormalizer object.
*
* @param \Drupal\serialization\LinkManager\LinkManagerInterface $link_manager
* @param \Drupal\hal\LinkManager\LinkManagerInterface $link_manager
* The hypermedia link manager.
* @param \Drupal\serialization\EntityResolver\EntityResolverInterface $entity_Resolver
* The entity resolver.
......
......@@ -4,7 +4,7 @@
use Drupal\Core\Entity\EntityManagerInterface;
use Drupal\Core\Extension\ModuleHandlerInterface;
use Drupal\serialization\LinkManager\LinkManagerInterface;
use Drupal\hal\LinkManager\LinkManagerInterface;
use GuzzleHttp\ClientInterface;
/**
......@@ -33,7 +33,7 @@ class FileEntityNormalizer extends ContentEntityNormalizer {
* The entity manager.
* @param \GuzzleHttp\ClientInterface $http_client
* The HTTP Client.
* @param \Drupal\serialization\LinkManager\LinkManagerInterface $link_manager
* @param \Drupal\hal\LinkManager\LinkManagerInterface $link_manager
* The hypermedia link manager.
* @param \Drupal\Core\Extension\ModuleHandlerInterface $module_handler
* The module handler.
......
......@@ -3,7 +3,7 @@
/**
* @file
* Contains database additions to drupal-8.bare.standard.php.gz for testing the
* upgrade path of serialization_update_8301().
* upgrade path of hal_update_8301().
*/
use Drupal\Core\Database\Database;
......@@ -12,6 +12,11 @@
// Set the schema version.
$connection->insert('key_value')
->fields([
'collection' => 'system.schema',
'name' => 'hal',
'value' => 'i:8000;',
])
->fields([
'collection' => 'system.schema',
'name' => 'serialization',
......@@ -27,6 +32,7 @@
->execute()
->fetchField();
$extensions = unserialize($extensions);
$extensions['module']['hal'] = 0;
$extensions['module']['serialization'] = 0;
$connection->update('config')
->fields([
......
name: HAL test module
type: module
description: "Support module for HAL tests."
package: Testing
version: VERSION
core: 8.x
......@@ -2,33 +2,33 @@
/**
* @file
* Contains hook implementations for testing Serialization module.
* Contains hook implementations for testing HAL module.
*/
/**
* Implements hook_serialization_type_uri_alter().
* Implements hook_hal_type_uri_alter().
*/
function serialization_test_serialization_type_uri_alter(&$uri, $context = array()) {
if (!empty($context['serialization_test'])) {
$uri = 'serialization_test_type';
function hal_test_hal_type_uri_alter(&$uri, $context = array()) {
if (!empty($context['hal_test'])) {
$uri = 'hal_test_type';
}
}
/**
* Implements hook_rest_relation_uri_alter().
* Implements hook_hal_relation_uri_alter().
*/
function serialization_test_serialization_relation_uri_alter(&$uri, $context = array()) {
if (!empty($context['serialization_test'])) {
$uri = 'serialization_test_relation';
function hal_test_hal_relation_uri_alter(&$uri, $context = array()) {
if (!empty($context['hal_test'])) {
$uri = 'hal_test_relation';
}
}
/**
* Implements hook_rest_type_uri_alter().
*
* @deprecated Kept only for BC test coverage, see \Drupal\Tests\serialization\Kernel\SerializationLinkManagerTest::testGetTypeUri().
* @deprecated Kept only for BC test coverage, see \Drupal\Tests\hal\Kernel\HalLinkManagerTest::testGetTypeUri().
*/
function serialization_test_rest_type_uri_alter(&$uri, $context = array()) {
function hal_test_rest_type_uri_alter(&$uri, $context = array()) {
if (!empty($context['rest_test'])) {
$uri = 'rest_test_type';
}
......@@ -37,9 +37,9 @@ function serialization_test_rest_type_uri_alter(&$uri, $context = array()) {
/**
* Implements hook_rest_relation_uri_alter().
*
* @deprecated Kept only for BC test coverage, see \Drupal\Tests\serialization\Kernel\SerializationLinkManagerTest::testGetRelationUri().
* @deprecated Kept only for BC test coverage, see \Drupal\Tests\hal\Kernel\HalLinkManagerTest::testGetRelationUri().
*/
function serialization_test_rest_relation_uri_alter(&$uri, $context = array()) {
function hal_test_rest_relation_uri_alter(&$uri, $context = array()) {
if (!empty($context['rest_test'])) {
$uri = 'rest_test_relation';
}
......
......@@ -92,7 +92,7 @@ protected function removeFieldsFromNormalization(array $normalization, $field_na
* {@inheritdoc}
*/
protected function assertNormalizationEdgeCases($method, Url $url, array $request_options) {
// \Drupal\serialization\Normalizer\EntityNormalizer::denormalize(): entity
// \Drupal\hal\Normalizer\EntityNormalizer::denormalize(): entity
// types with bundles MUST send their bundle field to be denormalizable.
if ($this->entity->getEntityType()->hasKey('bundle')) {
$normalization = $this->getNormalizedPostEntity();
......
<?php
namespace Drupal\Tests\serialization\Functional\Update;
namespace Drupal\Tests\hal\Functional\Update;
use Drupal\system\Tests\Update\UpdatePathTestBase;
/**
* Tests that 'serialization.settings' is created, to store 'link_domain'.
* Tests that 'hal.settings' is created, to store 'link_domain'.
*
* @see https://www.drupal.org/node/2758897
*
* @group serialization
* @group hal
*/
class CreateSerializationSettingsForLinkDomainUpdateTest extends UpdatePathTestBase {
/**
* {@inheritdoc}
*/
protected static $modules = ['serialization'];
class CreateHalSettingsForLinkDomainUpdateTest extends UpdatePathTestBase {
/**
* {@inheritdoc}
......@@ -24,24 +19,24 @@ class CreateSerializationSettingsForLinkDomainUpdateTest extends UpdatePathTestB
public function setDatabaseDumpFiles() {
$this->databaseDumpFiles = [
__DIR__ . '/../../../../../system/tests/fixtures/update/drupal-8.bare.standard.php.gz',
__DIR__ . '/../../../fixtures/update/drupal-8.serialization-serialization_update_8301.php',
__DIR__ . '/../../../fixtures/update/drupal-8.hal-hal_update_8301.php',
];
}
/**
* Tests serialization_update_8301().
* Tests hal_update_8301().
*/
public function testSerializationSettingsCreated() {
public function testHalSettingsCreated() {
// Make sure we have the expected values before the update.
$serialization_settings = $this->config('serialization.settings');
$this->assertIdentical([], $serialization_settings->getRawData());
$hal_settings = $this->config('hal.settings');
$this->assertIdentical([], $hal_settings->getRawData());
$this->runUpdates();
// Make sure we have the expected values after the update.
$serialization_settings = \Drupal::configFactory()->get('serialization.settings');
$this->assertTrue(array_key_exists('link_domain', $serialization_settings->getRawData()));
$this->assertIdentical(NULL, $serialization_settings->getRawData()['link_domain']);
$hal_settings = \Drupal::configFactory()->get('hal.settings');
$this->assertTrue(array_key_exists('link_domain', $hal_settings->getRawData()));
$this->assertIdentical(NULL, $hal_settings->getRawData()['link_domain']);
}
}
<?php
namespace Drupal\Tests\serialization\Functional\Update;
namespace Drupal\Tests\hal\Functional\Update;
use Drupal\system\Tests\Update\UpdatePathTestBase;
/**
* 'link_domain' is migrated from 'rest.settings' to 'serialization.settings'.
* 'link_domain' is migrated from 'rest.settings' to 'hal.settings'.
*
* @see https://www.drupal.org/node/2758897
*
* @group serialization
* @group hal
*/
class MigrateLinkDomainSettingFromRestToSerializationUpdateTest extends UpdatePathTestBase {
/**
* {@inheritdoc}
*/
protected static $modules = ['rest', 'serialization'];
class MigrateLinkDomainSettingFromRestToHalUpdateTest extends UpdatePathTestBase {
/**
* {@inheritdoc}
......@@ -24,18 +19,18 @@ class MigrateLinkDomainSettingFromRestToSerializationUpdateTest extends UpdatePa
public function setDatabaseDumpFiles() {
$this->databaseDumpFiles = [
__DIR__ . '/../../../../../system/tests/fixtures/update/drupal-8.bare.standard.php.gz',
__DIR__ . '/../../../fixtures/update/drupal-8.serialization-serialization_update_8301.php',
__DIR__ . '/../../../fixtures/update/drupal-8.rest-serialization_update_8301.php',
__DIR__ . '/../../../fixtures/update/drupal-8.hal-hal_update_8301.php',
__DIR__ . '/../../../fixtures/update/drupal-8.rest-hal_update_8301.php',
];
}
/**
* Tests serialization_update_8301().
* Tests hal_update_8301().
*/
public function testLinkDomainMigratedFromRestSettingsToSerializationSettings() {
public function testLinkDomainMigratedFromRestSettingsToHalSettings() {
// Make sure we have the expected values before the update.
$serialization_settings = $this->config('serialization.settings');
$this->assertIdentical([], $serialization_settings->getRawData());
$hal_settings = $this->config('hal.settings');
$this->assertIdentical([], $hal_settings->getRawData());
$rest_settings = $this->config('rest.settings');
$this->assertTrue(array_key_exists('link_domain', $rest_settings->getRawData()));
$this->assertIdentical('http://example.com', $rest_settings->getRawData()['link_domain']);
......@@ -43,9 +38,9 @@ public function testLinkDomainMigratedFromRestSettingsToSerializationSettings()
$this->runUpdates();
// Make sure we have the expected values after the update.
$serialization_settings = \Drupal::configFactory()->get('serialization.settings');
$this->assertTrue(array_key_exists('link_domain', $serialization_settings->getRawData()));
$this->assertIdentical('http://example.com', $serialization_settings->getRawData()['link_domain']);
$hal_settings = \Drupal::configFactory()->get('hal.settings');
$this->assertTrue(array_key_exists('link_domain', $hal_settings->getRawData()));
$this->assertIdentical('http://example.com', $hal_settings->getRawData()['link_domain']);
$rest_settings = $this->config('rest.settings');
$this->assertFalse(array_key_exists('link_domain', $rest_settings->getRawData()));
}
......
......@@ -5,11 +5,11 @@
use Drupal\Core\Cache\MemoryBackend;
use Drupal\file\Entity\File;
use Drupal\hal\Encoder\JsonEncoder;
use Drupal\hal\LinkManager\LinkManager;
use Drupal\hal\LinkManager\RelationLinkManager;
use Drupal\hal\LinkManager\TypeLinkManager;
use Drupal\hal\Normalizer\FieldItemNormalizer;
use Drupal\hal\Normalizer\FileEntityNormalizer;
use Drupal\serialization\LinkManager\LinkManager;
use Drupal\serialization\LinkManager\RelationLinkManager;
use Drupal\serialization\LinkManager\TypeLinkManager;
use Symfony\Component\Serializer\Serializer;
......
<?php
namespace Drupal\Tests\serialization\Kernel;
namespace Drupal\Tests\hal\Kernel;
use Drupal\Core\Url;
use Drupal\KernelTests\KernelTestBase;
/**
* @coversDefaultClass \Drupal\serialization\LinkManager\LinkManager
* @group serialization
* @coversDefaultClass \Drupal\hal\LinkManager\LinkManager
* @group hal
*/
class SerializationLinkManagerTest extends KernelTestBase {
class HalLinkManagerTest extends KernelTestBase {
/**
* {@inheritdoc}
*/
public static $modules = ['serialization', 'serialization_test', 'system'];
public static $modules = ['hal', 'hal_test', 'serialization', 'system'];
/**
* {@inheritdoc}
......@@ -29,13 +29,13 @@ protected function setUp() {
*/
public function testGetTypeUri() {
/* @var \Drupal\rest\LinkManager\TypeLinkManagerInterface $type_manager */
$type_manager = \Drupal::service('serialization.link_manager.type');
$type_manager = \Drupal::service('hal.link_manager.type');
$base = Url::fromRoute('<front>', [], ['absolute' => TRUE])->toString();
$link = $type_manager->getTypeUri('node', 'page');
$this->assertSame($link, $base . 'rest/type/node/page');
// Now with optional context.
$link = $type_manager->getTypeUri('node', 'page', ['serialization_test' => TRUE]);
$this->assertSame($link, 'serialization_test_type');
$link = $type_manager->getTypeUri('node', 'page', ['hal_test' => TRUE]);
$this->assertSame($link, 'hal_test_type');
// Test BC: hook_rest_type_uri_alter().
$link = $type_manager->getTypeUri('node', 'page', ['rest_test' => TRUE]);
$this->assertSame($link, 'rest_test_type');
......@@ -46,13 +46,13 @@ public function testGetTypeUri() {
*/
public function testGetRelationUri() {
/* @var \Drupal\rest\LinkManager\RelationLinkManagerInterface $relation_manager */
$relation_manager = \Drupal::service('serialization.link_manager.relation');
$relation_manager = \Drupal::service('hal.link_manager.relation');
$base = Url::fromRoute('<front>', [], ['absolute' => TRUE])->toString();
$link = $relation_manager->getRelationUri('node', 'page', 'field_ref');
$this->assertSame($link, $base . 'rest/relation/node/page/field_ref');
// Now with optional context.
$link = $relation_manager->getRelationUri('node', 'page', 'foobar', ['serialization_test' => TRUE]);
$this->assertSame($link, 'serialization_test_relation');
$link = $relation_manager->getRelationUri('node', 'page', 'foobar', ['hal_test' => TRUE]);
$this->assertSame($link, 'hal_test_relation');
// Test BC: hook_rest_relation_uri_alter().
$link = $relation_manager->getRelationUri('node', 'page', 'foobar', ['rest_test' => TRUE]);
$this->assertSame($link, 'rest_test_relation');
......@@ -61,9 +61,9 @@ public function testGetRelationUri() {
/**
* @covers ::setLinkDomain
*/
public function testSerializationLinkManagersSetLinkDomain() {
public function testHalLinkManagersSetLinkDomain() {
/* @var \Drupal\rest\LinkManager\LinkManager $link_manager */
$link_manager = \Drupal::service('serialization.link_manager');
$link_manager = \Drupal::service('hal.link_manager');
$link_manager->setLinkDomain('http://example.com/');
$link = $link_manager