Skip to content
Snippets Groups Projects
Commit cfc887b2 authored by Oleksandr Anton4yk's avatar Oleksandr Anton4yk Committed by Oleksandr Kuzava
Browse files

issue #3298996: Support content moderation

parent eb7bd48f
No related branches found
No related tags found
1 merge request!36issue #3298996: Support content moderation
......@@ -272,6 +272,7 @@ class ContentExporter implements ContentExporterInterface {
* {@inheritdoc}
*/
public function exportBaseValues(FieldableEntityInterface $entity): array {
$base_fields = [];
$entity_type = $entity->getEntityTypeId();
switch ($entity_type) {
......@@ -279,7 +280,7 @@ class ContentExporter implements ContentExporterInterface {
if ($entity instanceof NodeInterface) {
$owner = $entity->getOwner();
return [
$base_fields = [
'title' => $entity->getTitle(),
'status' => $entity->isPublished(),
'langcode' => $entity->language()->getId(),
......@@ -294,7 +295,7 @@ class ContentExporter implements ContentExporterInterface {
case 'block_content':
if ($entity instanceof BlockContentInterface) {
return [
$base_fields = [
'info' => $entity->label(),
'reusable' => $entity->isReusable(),
'langcode' => $entity->language()->getId(),
......@@ -306,7 +307,7 @@ class ContentExporter implements ContentExporterInterface {
case 'media':
if ($entity instanceof MediaInterface) {
return [
$base_fields = [
'name' => $entity->getName(),
'created' => $entity->getCreatedTime(),
'status' => $entity->isPublished(),
......@@ -317,7 +318,7 @@ class ContentExporter implements ContentExporterInterface {
case 'user':
if ($entity instanceof UserInterface) {
return [
$base_fields = [
'mail' => $entity->getEmail(),
'init' => $entity->getInitialEmail(),
'name' => $entity->getAccountName(),
......@@ -330,7 +331,7 @@ class ContentExporter implements ContentExporterInterface {
case 'taxonomy_term':
if ($entity instanceof TermInterface) {
return [
$base_fields = [
'name' => $entity->getName(),
'weight' => $entity->getWeight(),
'langcode' => $entity->language()->getId(),
......@@ -343,7 +344,7 @@ class ContentExporter implements ContentExporterInterface {
break;
case 'paragraph':
return [
$base_fields = [
'status' => $entity->isPublished(),
'langcode' => $entity->language()->getId(),
'created' => $entity->getCreatedTime(),
......@@ -355,8 +356,12 @@ class ContentExporter implements ContentExporterInterface {
return [];
}
// No base fields found for the entity.
return [];
// Support moderation state for multiple entity types.
if ($entity->hasField('moderation_state') && !$entity->get('moderation_state')->isEmpty()) {
$base_fields['moderation_state'] = $entity->get('moderation_state')->value;
}
return $base_fields;
}
/**
......
......@@ -554,23 +554,24 @@ class ContentImporter implements ContentImporterInterface {
public function mapBaseFieldsValues(string $entity_type_id, array $values): array {
switch ($entity_type_id) {
case 'node':
$node = [
$entity = [
'title' => $values['title'],
'langcode' => $values['langcode'],
'created' => $values['created'],
'status' => $values['status'],
];
// We check if node url alias is filled in.
if (isset($values['url'])) {
$node['path'] = [
$entity['path'] = [
'alias' => $values['url'],
'pathauto' => empty($values['url']),
];
}
return $node;
break;
case 'user':
return [
$entity = [
'mail' => $values['mail'],
'init' => $values['init'],
'name' => $values['name'],
......@@ -578,40 +579,52 @@ class ContentImporter implements ContentImporterInterface {
'status' => $values['status'],
'timezone' => $values['timezone'],
];
break;
case 'block_content':
return [
$entity = [
'langcode' => $values['langcode'],
'info' => $values['info'],
'reusable' => $values['reusable'],
];
break;
case 'media':
return [
$entity = [
'langcode' => $values['langcode'],
'name' => $values['name'],
'status' => $values['status'],
'created' => $values['created'],
];
break;
case 'taxonomy_term':
return [
$entity = [
'name' => $values['name'],
'weight' => $values['weight'],
'langcode' => $values['langcode'],
'description' => $values['description'],
];
break;
case 'paragraph':
return [
$entity = [
'langcode' => $values['langcode'],
'created' => $values['created'],
'status' => $values['status'],
];
break;
default:
return [];
}
// Set moderation state if it is supported for multiple entities.
if (isset($values['moderation_state'])) {
$entity['moderation_state'] = $values['moderation_state'];
}
return $entity;
}
/**
......
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