Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
H
helper
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
helper
Merge requests
!46
Added Plugin::getTypeFromManager() with tests.
Code
Review changes
Check out branch
Download
Patches
Plain diff
Open
Added Plugin::getTypeFromManager() with tests.
issue/helper-3414461:3414461-add-plugingettypefrommanager
into
8.x-1.x
Overview
0
Commits
6
Pipelines
5
Changes
5
Open
Dave Reid
requested to merge
issue/helper-3414461:3414461-add-plugingettypefrommanager
into
8.x-1.x
1 year ago
Overview
0
Commits
6
Pipelines
5
Changes
5
Expand
Closes
#3414461
0
0
Merge request reports
Compare
8.x-1.x
version 4
8ba4f533
1 year ago
version 3
44b517b9
1 year ago
version 2
976440c3
1 year ago
version 1
39d32a56
1 year ago
8.x-1.x (base)
and
latest version
latest version
ad42626b
6 commits,
1 year ago
version 4
8ba4f533
5 commits,
1 year ago
version 3
44b517b9
4 commits,
1 year ago
version 2
976440c3
3 commits,
1 year ago
version 1
39d32a56
1 commit,
1 year ago
5 files
+
62
−
1
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
Files
5
Search (e.g. *.vue) (Ctrl+P)
src/Plugin.php
+
17
−
0
Options
@@ -2,6 +2,7 @@
namespace
Drupal\helper
;
use
Drupal\Component\DependencyInjection\ReverseContainer
;
use
Drupal\Component\Plugin\CategorizingPluginManagerInterface
;
use
Drupal\Component\Plugin\FallbackPluginManagerInterface
;
use
Drupal\Component\Plugin\PluginManagerInterface
;
@@ -36,6 +37,22 @@ class Plugin {
return
$plugin_manager
;
}
/**
* Get the plugin type from a plugin manager object.
*
* @param \Drupal\Component\Plugin\PluginManagerInterface $manager
* The plugin manager.
*
* @return string|null
* The plugin type if found, otherwise NULL.
*/
public
static
function
getTypeFromManager
(
PluginManagerInterface
$manager
):
?string
{
$service_id
=
\Drupal
::
service
(
ReverseContainer
::
class
)
->
getId
(
$manager
);
if
(
$service_id
&&
str_starts_with
(
$service_id
,
'plugin.manager.'
))
{
return
str_replace
(
'plugin.manager.'
,
''
,
$service_id
);
}
}
/**
* Call a plugin callback and return its result.
*
Loading