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
f993931f
Commit
f993931f
authored
2 years ago
by
Ivan Doroshenko
Browse files
Options
Downloads
Patches
Plain Diff
Issue
#3253347
by Matroskeen: Allow to use several bundles in entity_lookup plugin
parent
dae1881a
No related branches found
No related tags found
1 merge request
!8
Issue #3229479: Entity_lookup taxonomy_term restricted by VID
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/Plugin/migrate/process/EntityLookup.php
+3
-2
3 additions, 2 deletions
src/Plugin/migrate/process/EntityLookup.php
tests/src/Kernel/Plugin/migrate/process/EntityLookupTest.php
+41
-0
41 additions, 0 deletions
tests/src/Kernel/Plugin/migrate/process/EntityLookupTest.php
with
44 additions
and
2 deletions
src/Plugin/migrate/process/EntityLookup.php
+
3
−
2
View file @
f993931f
...
...
@@ -37,7 +37,8 @@ use Symfony\Component\DependencyInjection\ContainerInterface;
* values. Defaults to '=' for scalar values and 'IN' for arrays.
* - bundle_key: (optional) The name of the bundle field on the entity type
* being queried.
* - bundle: (optional) The value to query for the bundle.
* - bundle: (optional) The value to query for the bundle - can be a string or
* an array.
* - access_check: (optional) Indicates if access to the entity for this user
* will be checked. Default is true.
* - ignore_case: (optional) Whether to ignore case in the query. Defaults to
...
...
@@ -250,7 +251,7 @@ class EntityLookup extends ProcessPluginBase implements ContainerFactoryPluginIn
}
if
(
$this
->
lookupBundleKey
)
{
$query
->
condition
(
$this
->
lookupBundleKey
,
$this
->
lookupBundle
);
$query
->
condition
(
$this
->
lookupBundleKey
,
(
array
)
$this
->
lookupBundle
,
'IN'
);
}
$results
=
$query
->
execute
();
...
...
This diff is collapsed.
Click to expand it.
tests/src/Kernel/Plugin/migrate/process/EntityLookupTest.php
+
41
−
0
View file @
f993931f
...
...
@@ -187,4 +187,45 @@ final class EntityLookupTest extends KernelTestBase {
];
}
/**
* Tests a lookup with bundle conditions.
*/
public
function
testEntityLookupWithBundles
():
void
{
$migration
=
\Drupal
::
service
(
'plugin.manager.migration'
)
->
createStubMigration
([
'id'
=>
'test'
,
'source'
=>
[],
'process'
=>
[],
'destination'
=>
[
'plugin'
=>
'entity:node'
,
],
]);
// Create a node of article content type.
$this
->
createNode
([
'title'
=>
'article 1'
,
'type'
=>
'article'
,
]);
$configuration
=
[
'entity_type'
=>
'node'
,
'value_key'
=>
'title'
,
'bundle_key'
=>
'type'
,
'bundle'
=>
'page'
,
];
// The search is performed by one bundle - node is not found.
$plugin
=
\Drupal
::
service
(
'plugin.manager.migrate.process'
)
->
createInstance
(
'entity_lookup'
,
$configuration
,
$migration
);
$value
=
$plugin
->
transform
(
'article 1'
,
$this
->
migrateExecutable
,
new
Row
(),
'destination_property'
);
$this
->
assertEquals
(
NULL
,
$value
);
// Now include both bundles in the search - node is found.
$configuration
[
'bundle'
]
=
[
'page'
,
'article'
];
$plugin
=
\Drupal
::
service
(
'plugin.manager.migrate.process'
)
->
createInstance
(
'entity_lookup'
,
$configuration
,
$migration
);
$value
=
$plugin
->
transform
(
'article 1'
,
$this
->
migrateExecutable
,
new
Row
(),
'destination_property'
);
$this
->
assertEquals
(
'4'
,
$value
);
}
}
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