Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
drupal
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
drupal
Merge requests
!2899
Resolve
#2852463
"Configurable plugin trait 10.1"
Code
Review changes
Check out branch
Download
Patches
Plain diff
Open
Resolve
#2852463
"Configurable plugin trait 10.1"
issue/drupal-2852463:2852463-configurable-plugin-trait-10.1
into
10.1.x
Overview
0
Commits
11
Pipelines
0
Changes
13
Open
Joachim Noreiko
requested to merge
issue/drupal-2852463:2852463-configurable-plugin-trait-10.1
into
10.1.x
2 years ago
Overview
0
Commits
11
Pipelines
0
Changes
13
Expand
Closes
#2852463
0
0
Merge request reports
Compare
10.1.x
version 2
b46eb078
2 years ago
version 1
75ff688d
2 years ago
10.1.x (HEAD)
and
latest version
latest version
6cf14bb4
11 commits,
2 years ago
version 2
b46eb078
5 commits,
2 years ago
version 1
75ff688d
4 commits,
2 years ago
13 files
+
321
−
171
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
Files
13
Search (e.g. *.vue) (Ctrl+P)
core/lib/Drupal/Component/Plugin/ConfigurableTrait.php
0 → 100644
+
66
−
0
Options
<?php
namespace
Drupal\Component\Plugin
;
use
Drupal\Component\Utility\NestedArray
;
/**
* Implements \Drupal\Component\Plugin\ConfigurableInterface.
*
* In order for configurable plugins to maintain their configuration, the
* default configuration must be merged into any explicitly defined
* configuration. This trait provides the appropriate getters and setters to
* handle this logic, removing the need for excess boilerplate.
*
* @ingroup Plugin
*/
trait
ConfigurableTrait
{
/**
* Configuration information passed into the plugin.
*
* @var array
*/
protected
$configuration
;
/**
* Gets this plugin's configuration.
*
* @return array
* An array of this plugin's configuration.
*
* @see \Drupal\Component\Plugin\ConfigurableInterface::getConfiguration()
*/
public
function
getConfiguration
()
{
return
$this
->
configuration
;
}
/**
* Sets the configuration for this plugin instance.
*
* @param array $configuration
* An associative array containing the plugin's configuration. Provided
* value is merged with default configuration.
*
* @return $this
*
* @see \Drupal\Component\Plugin\ConfigurableInterface::setConfiguration()
*/
public
function
setConfiguration
(
array
$configuration
)
{
$this
->
configuration
=
NestedArray
::
mergeDeepArray
([
$this
->
defaultConfiguration
(),
$configuration
],
TRUE
);
return
$this
;
}
/**
* Gets default configuration for this plugin.
*
* @return array
* An associative array with the default configuration.
*
* @see \Drupal\Component\Plugin\ConfigurableInterface::defaultConfiguration()
*/
public
function
defaultConfiguration
()
{
return
[];
}
}
Loading