Unverified Commit 499396e2 authored by andypost's avatar andypost Committed by larowlan

Issue #2867579 by andypost, wengerk, alexpott, larowlan, pmagunia, waspper: Core 8.3 compatibility

parent 206190fe
......@@ -4,5 +4,7 @@
"type": "drupal-module",
"license": "GPL-2.0+",
"minimum-stability": "dev",
"require": { }
"require": {
"drupal/core": "~8.3"
}
}
......@@ -4,5 +4,5 @@ description: 'Imports default content when a module is enabled'
package: Web services
core: 8.x
dependencies:
- hal
- rest
- drupal:hal (>=8.3.x)
- drupal:rest
......@@ -5,10 +5,10 @@ services:
class: Drupal\default_content\Scanner
default_content.importer:
class: Drupal\default_content\Importer
arguments: ['@serializer', '@plugin.manager.rest', '@entity_type.manager', '@rest.link_manager', '@event_dispatcher', '@default_content.scanner', '%default_content.link_domain%', '@account_switcher']
arguments: ['@serializer', '@plugin.manager.rest', '@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', '@rest.link_manager', '@event_dispatcher', '@module_handler', '@info_parser', '%default_content.link_domain%']
arguments: ['@serializer', '@entity_type.manager', '@entity.repository', '@hal.link_manager', '@event_dispatcher', '@module_handler', '@info_parser', '%default_content.link_domain%']
default_content.config_subscriber:
class: Drupal\default_content\Config\DefaultContentConfigSubscriber
arguments: ['@default_content.importer']
......
......@@ -4,6 +4,7 @@ namespace Drupal\default_content;
use Drupal\Core\DependencyInjection\ContainerBuilder;
use Drupal\Core\DependencyInjection\ServiceProviderBase;
use Drupal\default_content\Normalizer\TermEntityNormalizer;
use Symfony\Component\DependencyInjection\Definition;
use Symfony\Component\DependencyInjection\Reference;
......@@ -20,8 +21,8 @@ class DefaultContentServiceProvider extends ServiceProviderBase {
// @todo Get rid of after https://www.drupal.org/node/2543726
if (isset($modules['taxonomy'])) {
// Add a normalizer service for term entities.
$service_definition = new Definition('Drupal\default_content\Normalizer\TermEntityNormalizer', [
new Reference('rest.link_manager'),
$service_definition = new Definition(TermEntityNormalizer::class, [
new Reference('hal.link_manager'),
new Reference('entity.manager'),
new Reference('module_handler'),
]);
......
......@@ -2,7 +2,6 @@
namespace Drupal\default_content;
use Drupal\Component\Render\FormattableMarkup;
use Drupal\Core\Entity\ContentEntityInterface;
use Drupal\Core\Entity\EntityRepositoryInterface;
use Drupal\Core\Entity\EntityTypeManagerInterface;
......@@ -10,7 +9,7 @@ use Drupal\Core\Extension\InfoParserInterface;
use Drupal\Core\Extension\ModuleHandlerInterface;
use Drupal\default_content\Event\DefaultContentEvents;
use Drupal\default_content\Event\ExportEvent;
use Drupal\rest\LinkManager\LinkManagerInterface;
use Drupal\hal\LinkManager\LinkManagerInterface;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
use Symfony\Component\Serializer\Serializer;
......@@ -66,7 +65,7 @@ class Exporter implements ExporterInterface {
/**
* The link manager service.
*
* @var \Drupal\rest\LinkManager\LinkManagerInterface
* @var \Drupal\hal\LinkManager\LinkManagerInterface
*/
protected $linkManager;
......@@ -86,7 +85,7 @@ class Exporter implements ExporterInterface {
* The entity type manager service.
* @param \Drupal\Core\Entity\EntityRepositoryInterface $entity_repository
* The entity repository service.
* @param \Drupal\rest\LinkManager\LinkManagerInterface $link_manager
* @param \Drupal\hal\LinkManager\LinkManagerInterface $link_manager
* The link manager service.
* @param \Symfony\Component\EventDispatcher\EventDispatcherInterface $event_dispatcher
* The event dispatcher.
......
......@@ -3,13 +3,12 @@
namespace Drupal\default_content;
use Drupal\Component\Graph\Graph;
use Drupal\Component\Render\FormattableMarkup;
use Drupal\Core\Config\Entity\ConfigEntityInterface;
use Drupal\Core\Entity\EntityTypeManagerInterface;
use Drupal\Core\Session\AccountSwitcherInterface;
use Drupal\default_content\Event\DefaultContentEvents;
use Drupal\default_content\Event\ImportEvent;
use Drupal\rest\LinkManager\LinkManagerInterface;
use Drupal\hal\LinkManager\LinkManagerInterface;
use Drupal\rest\Plugin\Type\ResourcePluginManager;
use Drupal\user\EntityOwnerInterface;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
......@@ -67,7 +66,7 @@ class Importer implements ImporterInterface {
/**
* The link manager service.
*
* @var \Drupal\rest\LinkManager\LinkManagerInterface
* @var \Drupal\hal\LinkManager\LinkManagerInterface
*/
protected $linkManager;
......@@ -101,7 +100,7 @@ class Importer implements ImporterInterface {
* The rest resource plugin manager.
* @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager
* The entity type manager service.
* @param \Drupal\rest\LinkManager\LinkManagerInterface $link_manager
* @param \Drupal\hal\LinkManager\LinkManagerInterface $link_manager
* The link manager service.
* @param \Symfony\Component\EventDispatcher\EventDispatcherInterface $event_dispatcher
* The event dispatcher.
......
......@@ -24,7 +24,7 @@ class TermEntityNormalizer extends ContentEntityNormalizer {
/**
* {@inheritdoc}
*/
public function normalize($entity, $format = NULL, array $context = array()) {
public function normalize($entity, $format = NULL, array $context = []) {
if ($parents = $this->getTermStorage()->loadParents($entity->id())) {
$entity->parent->setValue(array_keys($parents));
}
......
......@@ -5,4 +5,4 @@ description: 'Default content tests'
package: Web services
core: 8.x
dependencies:
- default_content
- default_content:default_content
......@@ -3,10 +3,10 @@
namespace Drupal\Tests\default_content\Functional;
use Drupal\Core\Config\FileStorage;
use Drupal\simpletest\BrowserTestBase;
use Drupal\simpletest\ContentTypeCreationTrait;
use Drupal\simpletest\NodeCreationTrait;
use Drupal\user\Entity\User;
use Drupal\Tests\BrowserTestBase;
/**
* Test import of default content.
......@@ -23,7 +23,7 @@ class DefaultContentTest extends BrowserTestBase {
*
* @var array
*/
public static $modules = array('rest', 'taxonomy', 'hal', 'default_content');
public static $modules = ['rest', 'taxonomy', 'hal', 'default_content'];
/**
* {@inheritdoc}
......@@ -38,7 +38,7 @@ class DefaultContentTest extends BrowserTestBase {
'mail' => 'user2@example.com',
'status' => TRUE,
])->save();
$this->createContentType(array('type' => 'page'));
$this->createContentType(['type' => 'page']);
}
/**
......@@ -46,7 +46,7 @@ class DefaultContentTest extends BrowserTestBase {
*/
public function testImport() {
// Enable the module and import the content.
\Drupal::service('module_installer')->install(array('default_content_test'), TRUE);
\Drupal::service('module_installer')->install(['default_content_test'], TRUE);
$this->rebuildContainer();
$this->doPostInstallTests();
......
......@@ -2,7 +2,6 @@
namespace Drupal\Tests\default_content\Kernel;
use Drupal\default_content\Exporter;
use Drupal\field\Tests\EntityReference\EntityReferenceTestTrait;
use Drupal\KernelTests\KernelTestBase;
use Drupal\node\Entity\Node;
......@@ -61,7 +60,7 @@ class ExporterIntegrationTest extends KernelTestBase {
/** @var \Symfony\Component\Serializer\Serializer $serializer */
$serializer = \Drupal::service('serializer');
\Drupal::service('rest.link_manager')
\Drupal::service('hal.link_manager')
->setLinkDomain($this->container->getParameter('default_content.link_domain'));
$expected = $serializer->serialize($term, 'hal_json', ['json_encode_options' => JSON_PRETTY_PRINT]);
......@@ -114,7 +113,7 @@ class ExporterIntegrationTest extends KernelTestBase {
/** @var \Symfony\Component\Serializer\Serializer $serializer */
$serializer = \Drupal::service('serializer');
\Drupal::service('rest.link_manager')
\Drupal::service('hal.link_manager')
->setLinkDomain($this->container->getParameter('default_content.link_domain'));
$expected_node = $serializer->serialize($node, 'hal_json', ['json_encode_options' => JSON_PRETTY_PRINT]);
$expected_user = $serializer->serialize($user, 'hal_json', ['json_encode_options' => JSON_PRETTY_PRINT]);
......@@ -178,7 +177,7 @@ class ExporterIntegrationTest extends KernelTestBase {
$node->save();
$node = Node::load($node->id());
$serializer = \Drupal::service('serializer');
\Drupal::service('rest.link_manager')
\Drupal::service('hal.link_manager')
->setLinkDomain($this->container->getParameter('default_content.link_domain'));
$expected_node = $serializer->serialize($node, 'hal_json', ['json_encode_options' => JSON_PRETTY_PRINT]);
......@@ -200,7 +199,7 @@ class ExporterIntegrationTest extends KernelTestBase {
$this->setExpectedException(\InvalidArgumentException::class);
// Should throw an exception for missing uuid in default_content_export_test
// Should throw an exception for missing uuid for the testing module.
$this->defaultContentManager->exportModuleContent('default_content_export_test');
}
......
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