Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
migrate_plus
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
migrate_plus
Commits
c7cb7068
Commit
c7cb7068
authored
6 years ago
by
David Valdez
Committed by
Lucas Hedding
6 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Issue
#2933306
by gnuget, jian he, heddn: EntityLookup fatal error on config entity type
parent
e0e50113
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/Plugin/migrate/process/EntityLookup.php
+3
-1
3 additions, 1 deletion
src/Plugin/migrate/process/EntityLookup.php
tests/src/Kernel/Plugin/migrate/process/EntityGenerateTest.php
+51
-1
51 additions, 1 deletion
.../src/Kernel/Plugin/migrate/process/EntityGenerateTest.php
with
54 additions
and
2 deletions
src/Plugin/migrate/process/EntityLookup.php
+
3
−
1
View file @
c7cb7068
...
@@ -2,6 +2,7 @@
...
@@ -2,6 +2,7 @@
namespace
Drupal\migrate_plus\Plugin\migrate\process
;
namespace
Drupal\migrate_plus\Plugin\migrate\process
;
use
Drupal\Core\Config\Entity\ConfigEntityInterface
;
use
Drupal\Core\Entity\EntityManagerInterface
;
use
Drupal\Core\Entity\EntityManagerInterface
;
use
Drupal\Core\Entity\EntityReferenceSelection\SelectionPluginManagerInterface
;
use
Drupal\Core\Entity\EntityReferenceSelection\SelectionPluginManagerInterface
;
use
Drupal\Core\Plugin\ContainerFactoryPluginInterface
;
use
Drupal\Core\Plugin\ContainerFactoryPluginInterface
;
...
@@ -275,7 +276,8 @@ class EntityLookup extends ProcessPluginBase implements ContainerFactoryPluginIn
...
@@ -275,7 +276,8 @@ class EntityLookup extends ProcessPluginBase implements ContainerFactoryPluginIn
if
(
!
$ignoreCase
)
{
if
(
!
$ignoreCase
)
{
// Returns the entity's identifier.
// Returns the entity's identifier.
foreach
(
$results
as
$k
=>
$identifier
)
{
foreach
(
$results
as
$k
=>
$identifier
)
{
$result_value
=
$this
->
entityManager
->
getStorage
(
$this
->
lookupEntityType
)
->
load
(
$identifier
)
->
{
$this
->
lookupValueKey
}
->
value
;
$entity
=
$this
->
entityManager
->
getStorage
(
$this
->
lookupEntityType
)
->
load
(
$identifier
);
$result_value
=
$entity
instanceof
ConfigEntityInterface
?
$entity
->
get
(
$this
->
lookupValueKey
)
:
$entity
->
get
(
$this
->
lookupValueKey
)
->
value
;
if
((
$multiple
&&
!
in_array
(
$result_value
,
$value
,
TRUE
))
||
(
!
$multiple
&&
$result_value
!==
$value
))
{
if
((
$multiple
&&
!
in_array
(
$result_value
,
$value
,
TRUE
))
||
(
!
$multiple
&&
$result_value
!==
$value
))
{
unset
(
$results
[
$k
]);
unset
(
$results
[
$k
]);
}
}
...
...
This diff is collapsed.
Click to expand it.
tests/src/Kernel/Plugin/migrate/process/EntityGenerateTest.php
+
51
−
1
View file @
c7cb7068
...
@@ -2,6 +2,7 @@
...
@@ -2,6 +2,7 @@
namespace
Drupal\Tests\migrate_plus\Kernel\Plugin\migrate\process
;
namespace
Drupal\Tests\migrate_plus\Kernel\Plugin\migrate\process
;
use
Drupal\Core\Config\Entity\ConfigEntityInterface
;
use
Drupal\Core\Field\FieldStorageDefinitionInterface
;
use
Drupal\Core\Field\FieldStorageDefinitionInterface
;
use
Drupal\Core\Language\LanguageInterface
;
use
Drupal\Core\Language\LanguageInterface
;
use
Drupal\field\Tests\EntityReference\EntityReferenceTestTrait
;
use
Drupal\field\Tests\EntityReference\EntityReferenceTestTrait
;
...
@@ -183,7 +184,9 @@ class EntityGenerateTest extends KernelTestBase implements MigrateMessageInterfa
...
@@ -183,7 +184,9 @@ class EntityGenerateTest extends KernelTestBase implements MigrateMessageInterfa
}
}
}
}
elseif
(
$entity
->
{
$property
}
->
getValue
())
{
elseif
(
$entity
->
{
$property
}
->
getValue
())
{
$this
->
assertEquals
(
$expectedValue
,
$entity
->
{
$property
}[
0
]
->
entity
->
$key
->
value
);
$referenced_entity
=
$entity
->
{
$property
}[
0
]
->
entity
;
$result_value
=
$referenced_entity
instanceof
ConfigEntityInterface
?
$referenced_entity
->
get
(
$key
)
:
$referenced_entity
->
get
(
$key
)
->
value
;
$this
->
assertEquals
(
$expectedValue
,
$result_value
);
}
}
else
{
else
{
$this
->
fail
(
"Expected value:
$expectedValue
does not exist in
$property
."
);
$this
->
fail
(
"Expected value:
$expectedValue
does not exist in
$property
."
);
...
@@ -708,6 +711,53 @@ class EntityGenerateTest extends KernelTestBase implements MigrateMessageInterfa
...
@@ -708,6 +711,53 @@ class EntityGenerateTest extends KernelTestBase implements MigrateMessageInterfa
],
],
],
],
],
],
'lookup config entity'
=>
[
'definition'
=>
[
'source'
=>
[
'plugin'
=>
'embedded_data'
,
'data_rows'
=>
[
[
'id'
=>
1
,
'name'
=>
'user 1'
,
'mail'
=>
'user1@user1.com'
,
'roles'
=>
[
'role_1'
],
],
],
'ids'
=>
[
'id'
=>
[
'type'
=>
'integer'
],
],
],
'process'
=>
[
'id'
=>
'id'
,
'name'
=>
'name'
,
'roles'
=>
[
'plugin'
=>
'entity_lookup'
,
'entity_type'
=>
'user_role'
,
'value_key'
=>
'id'
,
'source'
=>
'roles'
,
],
],
'destination'
=>
[
'plugin'
=>
'entity:user'
,
],
],
'expected'
=>
[
'row 1'
=>
[
'id'
=>
1
,
'name'
=>
'user 1'
,
'roles'
=>
[
'id'
=>
'role_1'
,
'label'
=>
'Role 1'
,
],
],
],
'pre seed'
=>
[
'user_role'
=>
[
'id'
=>
'role_1'
,
'label'
=>
'Role 1'
,
],
],
],
];
];
}
}
...
...
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