Skip to content
Snippets Groups Projects
Commit 6d91494f authored by Oleksandr Kuzava's avatar Oleksandr Kuzava
Browse files

Issue #3336402: Add PHP 7.4 support.

parent 53d21536
No related branches found
No related tags found
1 merge request!37Issue #3336402: Move to plugins
...@@ -21,7 +21,10 @@ use Drupal\Core\Field\FieldItemListInterface; ...@@ -21,7 +21,10 @@ use Drupal\Core\Field\FieldItemListInterface;
* @param \Drupal\Core\Field\FieldItemListInterface $field * @param \Drupal\Core\Field\FieldItemListInterface $field
* The field item list. * The field item list.
* *
* @deprecated in single_content_sync:1.4.0, and is removed from single_content_sync:2.0.0. * @deprecated in single_content_sync:1.4.0 and is removed from single_content_sync:2.0.0.
* Define a custom plugin to export value of the custom field type or
* implement the event subscriber to alter the existing value.
*
* @see https://www.drupal.org/project/single_content_sync/issues/3336402 * @see https://www.drupal.org/project/single_content_sync/issues/3336402
* @see \Drupal\single_content_sync\Annotation\SingleContentSyncFieldProcessor * @see \Drupal\single_content_sync\Annotation\SingleContentSyncFieldProcessor
*/ */
...@@ -45,7 +48,10 @@ function hook_content_export_field_value_alter(&$value, FieldItemListInterface $ ...@@ -45,7 +48,10 @@ function hook_content_export_field_value_alter(&$value, FieldItemListInterface $
* @param \Drupal\Core\Entity\FieldableEntityInterface $entity * @param \Drupal\Core\Entity\FieldableEntityInterface $entity
* The entity to be exported. * The entity to be exported.
* *
* @deprecated in single_content_sync:1.4.0, and is removed from single_content_sync:2.0.0. * @deprecated in single_content_sync:1.4.0 and is removed from single_content_sync:2.0.0.
* Define a custom plugin to export value of the custom entity or
* implement the event subscriber to alter the existing entity.
*
* @see https://www.drupal.org/project/single_content_sync/issues/3336402 * @see https://www.drupal.org/project/single_content_sync/issues/3336402
* @see \Drupal\single_content_sync\ContentExporter::doExportToArray() * @see \Drupal\single_content_sync\ContentExporter::doExportToArray()
* @see \Drupal\single_content_sync\Event\ExportEvent * @see \Drupal\single_content_sync\Event\ExportEvent
...@@ -66,7 +72,10 @@ function hook_content_export_entity_alter(array &$base_fields, FieldableEntityIn ...@@ -66,7 +72,10 @@ function hook_content_export_entity_alter(array &$base_fields, FieldableEntityIn
* @param \Drupal\Core\Entity\FieldableEntityInterface|null $entity * @param \Drupal\Core\Entity\FieldableEntityInterface|null $entity
* The entity to be imported which is just created or updated. * The entity to be imported which is just created or updated.
* *
* @deprecated in single_content_sync:1.4.0, and is removed from single_content_sync:2.0.0. * @deprecated in single_content_sync:1.4.0 and is removed from single_content_sync:2.0.0.
* Define a custom plugin to handle custom entity import or implement
* the event subscriber to alter import of the existing entity.
*
* @see https://www.drupal.org/project/single_content_sync/issues/3336402 * @see https://www.drupal.org/project/single_content_sync/issues/3336402
* @see \Drupal\single_content_sync\ContentImporter::doImport() * @see \Drupal\single_content_sync\ContentImporter::doImport()
* @see \Drupal\single_content_sync\Event\ImportEvent * @see \Drupal\single_content_sync\Event\ImportEvent
...@@ -93,7 +102,10 @@ function hook_content_import_entity_alter(array $content, FieldableEntityInterfa ...@@ -93,7 +102,10 @@ function hook_content_import_entity_alter(array $content, FieldableEntityInterfa
* @param string|array|bool $field_value * @param string|array|bool $field_value
* The raw field value of the field to be imported. * The raw field value of the field to be imported.
* *
* @deprecated in single_content_sync:1.4.0, and is removed from single_content_sync:2.0.0. * @deprecated in single_content_sync:1.4.0 and is removed from single_content_sync:2.0.0.
* Define a custom plugin to import value of the custom field type or
* implement the event subscriber to alter import of the existing value.
*
* @see https://www.drupal.org/project/single_content_sync/issues/3336402 * @see https://www.drupal.org/project/single_content_sync/issues/3336402
* @see \Drupal\single_content_sync\Annotation\SingleContentSyncFieldProcessor * @see \Drupal\single_content_sync\Annotation\SingleContentSyncFieldProcessor
*/ */
......
...@@ -10,6 +10,20 @@ use Drupal\Core\Entity\ContentEntityInterface; ...@@ -10,6 +10,20 @@ use Drupal\Core\Entity\ContentEntityInterface;
*/ */
class ExportEvent extends Event { class ExportEvent extends Event {
/**
* The entity being exported.
*
* @var \Drupal\Core\Entity\ContentEntityInterface
*/
protected ContentEntityInterface $entity;
/**
* The content being exported.
*
* @var array
*/
protected array $content;
/** /**
* Constructs a new ExportEvent object. * Constructs a new ExportEvent object.
* *
...@@ -18,10 +32,10 @@ class ExportEvent extends Event { ...@@ -18,10 +32,10 @@ class ExportEvent extends Event {
* @param array $content * @param array $content
* The content being exported. * The content being exported.
*/ */
public function __construct( public function __construct(ContentEntityInterface $entity, array $content) {
protected ContentEntityInterface $entity, $this->entity = $entity;
protected array $content, $this->content = $content;
) {} }
/** /**
* Gets the entity being exported. * Gets the entity being exported.
...@@ -57,7 +71,7 @@ class ExportEvent extends Event { ...@@ -57,7 +71,7 @@ class ExportEvent extends Event {
* *
* @return $this * @return $this
*/ */
public function setContent(array $content): static { public function setContent(array $content): self {
$this->content = $content; $this->content = $content;
return $this; return $this;
} }
......
...@@ -10,6 +10,20 @@ use Drupal\Core\Entity\ContentEntityInterface; ...@@ -10,6 +10,20 @@ use Drupal\Core\Entity\ContentEntityInterface;
*/ */
class ImportEvent extends Event { class ImportEvent extends Event {
/**
* The entity being imported. Could be either a new or existing entity.
*
* @var \Drupal\Core\Entity\ContentEntityInterface
*/
protected ContentEntityInterface $entity;
/**
* The content to import.
*
* @var array
*/
protected array $content;
/** /**
* Constructs a new ImportEvent object. * Constructs a new ImportEvent object.
* *
...@@ -18,10 +32,10 @@ class ImportEvent extends Event { ...@@ -18,10 +32,10 @@ class ImportEvent extends Event {
* @param array $content * @param array $content
* The content to import. * The content to import.
*/ */
public function __construct( public function __construct(ContentEntityInterface $entity, array $content) {
protected ContentEntityInterface $entity, $this->entity = $entity;
protected array $content, $this->content = $content;
) {} }
/** /**
* Gets the entity being imported. * Gets the entity being imported.
...@@ -70,7 +84,7 @@ class ImportEvent extends Event { ...@@ -70,7 +84,7 @@ class ImportEvent extends Event {
* *
* @return $this * @return $this
*/ */
public function setContent(array $content): static { public function setContent(array $content): self {
$this->content = $content; $this->content = $content;
return $this; return $this;
} }
......
...@@ -38,12 +38,7 @@ class TaxonomyTerm extends SingleContentSyncBaseFieldsProcessorPluginBase implem ...@@ -38,12 +38,7 @@ class TaxonomyTerm extends SingleContentSyncBaseFieldsProcessorPluginBase implem
* @param \Drupal\single_content_sync\ContentExporterInterface $exporter * @param \Drupal\single_content_sync\ContentExporterInterface $exporter
* The content exporter service. * The content exporter service.
*/ */
public function __construct( public function __construct(array $configuration, $plugin_id, $plugin_definition, ContentExporterInterface $exporter) {
array $configuration,
$plugin_id,
$plugin_definition,
ContentExporterInterface $exporter
) {
parent::__construct($configuration, $plugin_id, $plugin_definition); parent::__construct($configuration, $plugin_id, $plugin_definition);
$this->exporter = $exporter; $this->exporter = $exporter;
...@@ -71,8 +66,8 @@ class TaxonomyTerm extends SingleContentSyncBaseFieldsProcessorPluginBase implem ...@@ -71,8 +66,8 @@ class TaxonomyTerm extends SingleContentSyncBaseFieldsProcessorPluginBase implem
'langcode' => $entity->language()->getId(), 'langcode' => $entity->language()->getId(),
'description' => $entity->getDescription(), 'description' => $entity->getDescription(),
'parent' => $entity->get('parent')->target_id 'parent' => $entity->get('parent')->target_id
? $this->exporter->doExportToArray($entity->get('parent')->entity) ? $this->exporter->doExportToArray($entity->get('parent')->entity)
: 0, : 0,
]; ];
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment