Skip to content
Snippets Groups Projects
Commit 37ac8c40 authored by Patrick van Efferen's avatar Patrick van Efferen Committed by Peter Grond
Browse files

Issue #3287410: Automated Drupal 10 compatibility fixes

parent 1efd5e7b
No related branches found
No related tags found
1 merge request!14Issue #3287410: Automated Drupal 10 compatibility fixes
......@@ -2,4 +2,4 @@ name: External Entities
type: module
description: 'Allows using remote entities, for example through a REST interface.'
package: External Entities
core_version_requirement: ^8.8 || ^9
core_version_requirement: ^8.8 || ^9 || ^10
......@@ -2,6 +2,6 @@ name: External Entities pathauto
type: module
description: 'Allows using remote entities, for example through a REST interface.'
package: External Entities
core_version_requirement: ^8.8 || ^9
core_version_requirement: ^8.8 || ^9 || ^10
dependencies:
- external_entities:external_entities
......@@ -144,7 +144,7 @@ class ExternalEntity extends ContentEntityBase implements ExternalEntityInterfac
// Allow other modules to perform custom extraction logic.
$event = new ExternalEntityExtractRawDataEvent($this, $raw_data);
\Drupal::service('event_dispatcher')->dispatch(ExternalEntitiesEvents::EXTRACT_RAW_DATA, $event);
\Drupal::service('event_dispatcher')->dispatch($event, ExternalEntitiesEvents::EXTRACT_RAW_DATA);
return $event->getRawData();
}
......
......@@ -2,8 +2,8 @@
namespace Drupal\external_entities\Event;
use Symfony\Contracts\EventDispatcher\Event;
use Drupal\external_entities\ExternalEntityInterface;
use Symfony\Component\EventDispatcher\Event;
/**
* Defines a, external entity raw data extraction event.
......
......@@ -2,7 +2,7 @@
namespace Drupal\external_entities\Event;
use Symfony\Component\EventDispatcher\Event;
use Symfony\Contracts\EventDispatcher\Event;
/**
* Defines an external entity raw data mapping event.
......
......@@ -326,9 +326,13 @@ class ExternalEntityStorage extends ContentEntityStorageBase implements External
}
// Allow other modules to perform custom mapping logic.
$event = new ExternalEntityMapRawDataEvent($data[$id], $entity_values);
$this->eventDispatcher->dispatch(ExternalEntitiesEvents::MAP_RAW_DATA, $event);
$this->eventDispatcher->dispatch($event, ExternalEntitiesEvents::MAP_RAW_DATA);
$entities[$id] = new $this->entityClass($event->getEntityValues(), $this->entityTypeId);
try {
$entities[$id] = $this->doCreate($event->getEntityValues());
} catch (EntityStorageException $exception) {
watchdog_exception('external_entities', $exception);
}
$entities[$id]->enforceIsNew(FALSE);
}
......
......@@ -2,17 +2,16 @@
namespace Drupal\external_entities\FieldMapper;
use Drupal\Core\TypedData\Plugin\DataType\DateTimeIso8601;
use Drupal\Core\Datetime\DrupalDateTime;
use Drupal\Core\Entity\EntityFieldManagerInterface;
use Drupal\Core\Entity\EntityTypeManager;
use Drupal\Core\Field\FieldDefinitionInterface;
use Drupal\Core\Language\LanguageInterface;
use Drupal\Core\TypedData\PrimitiveInterface;
use Drupal\Core\TypedData\Type\DateTimeInterface;
use Drupal\Core\TypedData\TypedDataManagerInterface;
use Drupal\datetime\Plugin\Field\FieldType\DateTimeItemInterface;
use Drupal\datetime\Plugin\Field\FieldType\DateTimeItem;
use Drupal\datetime_range\Plugin\Field\FieldType\DateRangeItem;
use Drupal\external_entities\Plugin\PluginFormTrait;
use Symfony\Component\DependencyInjection\ContainerInterface;
......@@ -148,7 +147,7 @@ abstract class ExpressionFieldMapperBase extends FieldMapperBase implements Expr
foreach ($field_definitions as $field_name => $field_definition) {
$field_values = $this->extractFieldValuesFromRawData($field_definition, $raw_data, $context);
if (!empty($field_values)) {
$entity_values[$field_name][LanguageInterface::LANGCODE_DEFAULT] = $field_values;
$entity_values[$field_name] = $field_values;
}
}
......@@ -280,7 +279,7 @@ abstract class ExpressionFieldMapperBase extends FieldMapperBase implements Expr
if ($timestamp !== FALSE) {
if (get_class($typed_data) === 'Drupal\Core\TypedData\Plugin\DataType\DateTimeIso8601') {
assert($typed_data instanceof \Drupal\Core\TypedData\Plugin\DataType\DateTimeIso8601);
assert($typed_data instanceof DateTimeIso8601);
$datetime_type = $field_definition->getFieldStorageDefinition()->getSetting('datetime_type');
if ($datetime_type === DateTimeItem::DATETIME_TYPE_DATE) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment