Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
single_content_sync
Manage
Activity
Members
Labels
Plan
Wiki
Custom issue tracker
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Model registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
project
single_content_sync
Commits
cfc887b2
Commit
cfc887b2
authored
1 year ago
by
Oleksandr Anton4yk
Committed by
Oleksandr Kuzava
1 year ago
Browse files
Options
Downloads
Patches
Plain Diff
issue
#3298996
: Support content moderation
parent
eb7bd48f
No related branches found
No related tags found
1 merge request
!36
issue #3298996: Support content moderation
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/ContentExporter.php
+13
-8
13 additions, 8 deletions
src/ContentExporter.php
src/ContentImporter.php
+21
-8
21 additions, 8 deletions
src/ContentImporter.php
with
34 additions
and
16 deletions
src/ContentExporter.php
+
13
−
8
View file @
cfc887b2
...
...
@@ -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
;
}
/**
...
...
This diff is collapsed.
Click to expand it.
src/ContentImporter.php
+
21
−
8
View file @
cfc887b2
...
...
@@ -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'
]),
];
}
re
turn
$node
;
b
re
ak
;
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
;
}
/**
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment