Skip to content
Snippets Groups Projects
Commit d230ea68 authored by Alex Pott's avatar Alex Pott
Browse files

Issue #1889748 by tim.plunkett: Figure out what to do with ConfigMapper.

parent 5a4dceb2
No related branches found
No related tags found
2 merge requests!7452Issue #1797438. HTML5 validation is preventing form submit and not fully...,!789Issue #3210310: Adjust Database API to remove deprecated Drupal 9 code in Drupal 10
<?php
/**
* @file
* Contains \Drupal\Core\Plugin\Mapper\ConfigMapper.
*/
namespace Drupal\Core\Plugin\Mapper;
use Drupal\Component\Plugin\Mapper\MapperInterface;
use Drupal\Component\Plugin\PluginManagerInterface;
use Drupal\Component\Plugin\Exception\PluginException;
/**
* Retrieves plugin instances from the configuration system.
*/
class ConfigMapper implements MapperInterface {
/**
* The plugin manager instance used by this mapper.
*
* @var \Drupal\Component\Plugin\PluginManagerInterface
*/
protected $manager;
/**
* Constructs a \Drupal\Core\Plugin\Mapper\ConfigMapper object.
*
* @param \Drupal\Component\Plugin\PluginManagerInterface $manager
* The plugin manager instance to use for this mapper.
*/
public function __construct(PluginManagerInterface $manager) {
$this->manager = $manager;
}
/**
* Implements \Drupal\Component\Plugin\Mapper\MapperInterface::getInstance().
*/
public function getInstance(array $options) {
$config = config($options['config']);
if ($config) {
$plugin_id = $config->get('id');
$settings = $config->get();
$settings['config_id'] = $options['config'];
// Attempt to create an instance with this plugin ID and settings.
try {
return $this->manager->createInstance($plugin_id, $settings);
}
catch (PluginException $e) {
return FALSE;
}
}
return FALSE;
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment