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
Merge requests
!3
Issue
#3218356
: Process plugin: service
Code
Review changes
Check out branch
Download
Patches
Plain diff
Merged
Issue
#3218356
: Process plugin: service
issue/migrate_plus-3218356:3218356-process-plugin-service
into
8.x-5.x
Overview
19
Commits
13
Pipelines
0
Changes
2
All threads resolved!
Show all comments
Merged
Benji Fisher
requested to merge
issue/migrate_plus-3218356:3218356-process-plugin-service
into
8.x-5.x
3 years ago
Overview
19
Commits
13
Pipelines
0
Changes
2
All threads resolved!
Show all comments
Expand
0
0
Merge request reports
Compare
8.x-5.x
version 6
6fd99a32
3 years ago
version 5
63a70c50
3 years ago
version 4
47de6063
3 years ago
version 3
61cf887b
3 years ago
version 2
10c9102b
3 years ago
version 1
74d4fafc
3 years ago
8.x-5.x (base)
and
latest version
latest version
cea4fc6e
13 commits,
3 years ago
version 6
6fd99a32
13 commits,
3 years ago
version 5
63a70c50
13 commits,
3 years ago
version 4
47de6063
12 commits,
3 years ago
version 3
61cf887b
6 commits,
3 years ago
version 2
10c9102b
5 commits,
3 years ago
version 1
74d4fafc
4 commits,
3 years ago
2 files
+
174
−
0
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
Files
2
Search (e.g. *.vue) (Ctrl+P)
src/Plugin/migrate/process/Service.php
0 → 100644
+
56
−
0
Options
<?php
namespace
Drupal\migrate_plus\Plugin\migrate\process
;
use
Drupal\Core\Plugin\ContainerFactoryPluginInterface
;
use
Drupal\migrate\Plugin\migrate\process\Callback
;
use
Symfony\Component\DependencyInjection\ContainerInterface
;
/**
* Provides a plugin to use a callable from a service class.
*
* Example:
*
* @code
* process:
* filemime:
* plugin: service
* service: file.mime_type.guesser
* method: guessMimeType
* source: filename
* @endcode
*
* All options for the callback plugin can be used, except for 'callable',
* which will be ignored.
*
* @see \Drupal\migrate\Plugin\migrate\process\Callback
*
* @MigrateProcessPlugin(
* id = "service"
* )
*/
class
Service
extends
Callback
implements
ContainerFactoryPluginInterface
{
/**
* {@inheritdoc}
*/
public
static
function
create
(
ContainerInterface
$container
,
array
$configuration
,
$plugin_id
,
$plugin_definition
)
{
if
(
!
isset
(
$configuration
[
'service'
]))
{
throw
new
\InvalidArgumentException
(
'The "service" must be set.'
);
}
if
(
!
isset
(
$configuration
[
'method'
]))
{
throw
new
\InvalidArgumentException
(
'The "method" must be set.'
);
}
if
(
!
$container
->
has
(
$configuration
[
'service'
]))
{
throw
new
\InvalidArgumentException
(
sprintf
(
'You have requested the non-existent service "%s".'
,
$configuration
[
'service'
]));
}
$service
=
$container
->
get
(
$configuration
[
'service'
]);
if
(
!
method_exists
(
$service
,
$configuration
[
'method'
]))
{
throw
new
\InvalidArgumentException
(
sprintf
(
'The "%s" service has no method "%s".'
,
$configuration
[
'service'
],
$configuration
[
'method'
]));
}
$configuration
[
'callable'
]
=
[
$service
,
$configuration
[
'method'
]];
return
new
static
(
$configuration
,
$plugin_id
,
$plugin_definition
);
}
}
Loading