Unverified Commit 68c30918 authored by andypost's avatar andypost Committed by larowlan

Issue #2874159 by andypost, larowlan: Get rid of rest module dependency

parent 499396e2
......@@ -5,4 +5,3 @@ package: Web services
core: 8.x
dependencies:
- drupal:hal (>=8.3.x)
- drupal:rest
......@@ -5,7 +5,7 @@ services:
class: Drupal\default_content\Scanner
default_content.importer:
class: Drupal\default_content\Importer
arguments: ['@serializer', '@plugin.manager.rest', '@entity_type.manager', '@hal.link_manager', '@event_dispatcher', '@default_content.scanner', '%default_content.link_domain%', '@account_switcher']
arguments: ['@serializer', '@entity_type.manager', '@hal.link_manager', '@event_dispatcher', '@default_content.scanner', '%default_content.link_domain%', '@account_switcher']
default_content.exporter:
class: Drupal\default_content\Exporter
arguments: ['@serializer', '@entity_type.manager', '@entity.repository', '@hal.link_manager', '@event_dispatcher', '@module_handler', '@info_parser', '%default_content.link_domain%']
......
......@@ -9,7 +9,6 @@ use Drupal\Core\Session\AccountSwitcherInterface;
use Drupal\default_content\Event\DefaultContentEvents;
use Drupal\default_content\Event\ImportEvent;
use Drupal\hal\LinkManager\LinkManagerInterface;
use Drupal\rest\Plugin\Type\ResourcePluginManager;
use Drupal\user\EntityOwnerInterface;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
use Symfony\Component\Serializer\Serializer;
......@@ -35,13 +34,6 @@ class Importer implements ImporterInterface {
*/
protected $serializer;
/**
* The rest resource plugin manager.
*
* @var \Drupal\rest\Plugin\Type\ResourcePluginManager
*/
protected $resourcePluginManager;
/**
* The entity type manager.
*
......@@ -96,8 +88,6 @@ class Importer implements ImporterInterface {
*
* @param \Symfony\Component\Serializer\Serializer $serializer
* The serializer service.
* @param \Drupal\rest\Plugin\Type\ResourcePluginManager $resource_plugin_manager
* The rest resource plugin manager.
* @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager
* The entity type manager service.
* @param \Drupal\hal\LinkManager\LinkManagerInterface $link_manager
......@@ -111,9 +101,8 @@ class Importer implements ImporterInterface {
* @param \Drupal\Core\Session\AccountSwitcherInterface $account_switcher
* The account switcher.
*/
public function __construct(Serializer $serializer, ResourcePluginManager $resource_plugin_manager, EntityTypeManagerInterface $entity_type_manager, LinkManagerInterface $link_manager, EventDispatcherInterface $event_dispatcher, ScannerInterface $scanner, $link_domain, AccountSwitcherInterface $account_switcher) {
public function __construct(Serializer $serializer, EntityTypeManagerInterface $entity_type_manager, LinkManagerInterface $link_manager, EventDispatcherInterface $event_dispatcher, ScannerInterface $scanner, $link_domain, AccountSwitcherInterface $account_switcher) {
$this->serializer = $serializer;
$this->resourcePluginManager = $resource_plugin_manager;
$this->entityTypeManager = $entity_type_manager;
$this->linkManager = $link_manager;
$this->eventDispatcher = $event_dispatcher;
......@@ -189,10 +178,8 @@ class Importer implements ImporterInterface {
if (!empty($file_map[$link])) {
$file = $file_map[$link];
$entity_type_id = $file->entity_type_id;
$resource = $this->resourcePluginManager->createInstance('entity:' . $entity_type_id);
$definition = $resource->getPluginDefinition();
$class = $this->entityTypeManager->getDefinition($entity_type_id)->getClass();
$contents = $this->parseFile($file);
$class = $definition['serialization_class'];
$entity = $this->serializer->deserialize($contents, $class, 'hal_json', ['request_method' => 'POST']);
$entity->enforceIsNew(TRUE);
// Ensure that the entity is not owned by the anonymous user.
......
......@@ -23,7 +23,7 @@ class DefaultContentTest extends BrowserTestBase {
*
* @var array
*/
public static $modules = ['rest', 'taxonomy', 'hal', 'default_content'];
public static $modules = ['taxonomy', 'hal', 'default_content'];
/**
* {@inheritdoc}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment