Skip to content
Snippets Groups Projects
Commit c7cef844 authored by Antonio De Marco's avatar Antonio De Marco
Browse files

Rename UiPatternsSourceMapper to UiPatternsSource #5

parent 20b29a72
No related branches found
No related tags found
No related merge requests found
...@@ -5,14 +5,14 @@ namespace Drupal\ui_patterns\Annotation; ...@@ -5,14 +5,14 @@ namespace Drupal\ui_patterns\Annotation;
use Drupal\Component\Annotation\Plugin; use Drupal\Component\Annotation\Plugin;
/** /**
* Defines a UI Patterns Mapping Source item annotation object. * Defines a UI Patterns Source item annotation object.
* *
* @see \Drupal\ui_patterns\Plugin\UiPatternsMappingSourceManager * @see \Drupal\ui_patterns\Plugin\UiPatternsSourceManager
* @see plugin_api * @see plugin_api
* *
* @Annotation * @Annotation
*/ */
class UiPatternsMappingSource extends Plugin { class UiPatternsSource extends Plugin {
/** /**
* The plugin ID. * The plugin ID.
......
<?php
namespace Drupal\ui_patterns\Plugin;
use Drupal\Component\Plugin\PluginBase;
/**
* Base class for UI Patterns Mapping Source plugins.
*/
abstract class UiPatternsMappingSourceBase extends PluginBase implements UiPatternsMappingSourceInterface {
}
<?php
namespace Drupal\ui_patterns\Plugin;
use Drupal\Component\Plugin\PluginInspectionInterface;
/**
* Defines an interface for UI Patterns Mapping Source plugins.
*/
interface UiPatternsMappingSourceInterface extends PluginInspectionInterface {
}
<?php
namespace Drupal\ui_patterns\Plugin\UiPatterns\Source;
use Drupal\ui_patterns\Plugin\UiPatternsSourceBase;
/**
* Defines Fields API pattern source plugin.
*
* @UiPatternsSource(
* id = "field_source",
* label = @Translation("Field source")
* )
*/
class FieldSource extends UiPatternsSourceBase {
}
<?php
namespace Drupal\ui_patterns\Plugin\UiPatterns\Source;
use Drupal\ui_patterns\Plugin\UiPatternsSourceBase;
/**
* Defines tokens pattern source plugin.
*
* @UiPatternsSource(
* id = "token_source",
* label = @Translation("Token source")
* )
*/
class TokenSource extends UiPatternsSourceBase {
}
<?php
namespace Drupal\ui_patterns\Plugin;
use Drupal\Component\Plugin\PluginBase;
use Drupal\Component\Utility\NestedArray;
use Drupal\Core\Form\FormStateInterface;
use Drupal\ui_patterns\UiPatternsManager;
use Symfony\Component\DependencyInjection\ContainerInterface;
/**
* Base class for UI Patterns Source plugins.
*/
abstract class UiPatternsSourceBase extends PluginBase implements UiPatternsSourceInterface {
/**
* Patterns manager service.
*
* @var \Drupal\ui_patterns\UiPatternsManager
*/
protected $patternsManager;
/**
* UiPatternsSourceBase constructor.
*
* @param array $configuration
* A configuration array containing information about the plugin instance.
* @param string $plugin_id
* The plugin_id for the plugin instance.
* @param mixed $plugin_definition
* The plugin implementation definition.
*/
public function __construct(array $configuration, $plugin_id, $plugin_definition, UiPatternsManager $ui_patterns_manager) {
parent::__construct($configuration, $plugin_id, $plugin_definition);
$this->patternsManager = $ui_patterns_manager;
}
/**
* {@inheritdoc}
*/
public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) {
return new static(
$configuration,
$plugin_id,
$plugin_definition,
$container->get('plugin.manager.ui_patterns')
);
}
/**
* {@inheritdoc}
*/
public function getConfiguration() {
return $this->configuration;
}
/**
* {@inheritdoc}
*/
public function setConfiguration(array $configuration) {
$this->configuration = NestedArray::mergeDeep(
$this->baseConfigurationDefaults(),
$this->defaultConfiguration(),
$configuration
);
}
/**
* Returns generic default configuration for source mapper plugins.
*
* @return array
* An associative array with the default configuration.
*/
protected function baseConfigurationDefaults() {
return [
'id' => $this->getPluginId(),
'label' => '',
'provider' => $this->pluginDefinition['provider'],
];
}
/**
* {@inheritdoc}
*/
public function defaultConfiguration() {
return [];
}
/**
* {@inheritdoc}
*/
public function setConfigurationValue($key, $value) {
$this->configuration[$key] = $value;
}
/**
* {@inheritdoc}
*/
public function calculateDependencies() {
return [];
}
/**
* {@inheritdoc}
*/
public function buildConfigurationForm(array $form, FormStateInterface $form_state) {
return [];
}
/**
* {@inheritdoc}
*/
public function validateConfigurationForm(array &$form, FormStateInterface $form_state) {
}
/**
* {@inheritdoc}
*/
public function submitConfigurationForm(array &$form, FormStateInterface $form_state) {
// Process the block's submission handling if no errors occurred only.
if (!$form_state->getErrors()) {
}
}
}
<?php
namespace Drupal\ui_patterns\Plugin;
use Drupal\Component\Plugin\PluginInspectionInterface;
use Drupal\Component\Plugin\ConfigurablePluginInterface;
use Drupal\Core\Plugin\PluginFormInterface;
/**
* Defines an interface for UI Patterns Source plugins.
*/
interface UiPatternsSourceInterface extends PluginInspectionInterface, PluginFormInterface, ConfigurablePluginInterface {
}
...@@ -7,12 +7,12 @@ use Drupal\Core\Cache\CacheBackendInterface; ...@@ -7,12 +7,12 @@ use Drupal\Core\Cache\CacheBackendInterface;
use Drupal\Core\Extension\ModuleHandlerInterface; use Drupal\Core\Extension\ModuleHandlerInterface;
/** /**
* Provides the UI Patterns Mapping Source plugin manager. * Provides the UI Patterns Source plugin manager.
*/ */
class UiPatternsMappingSourceManager extends DefaultPluginManager { class UiPatternsSourceManager extends DefaultPluginManager {
/** /**
* Constructor for UiPatternsMappingSourceManager objects. * Constructor for UiPatternsSourceManager objects.
* *
* @param \Traversable $namespaces * @param \Traversable $namespaces
* An object that implements \Traversable which contains the root paths * An object that implements \Traversable which contains the root paths
...@@ -23,10 +23,10 @@ class UiPatternsMappingSourceManager extends DefaultPluginManager { ...@@ -23,10 +23,10 @@ class UiPatternsMappingSourceManager extends DefaultPluginManager {
* The module handler to invoke the alter hook with. * The module handler to invoke the alter hook with.
*/ */
public function __construct(\Traversable $namespaces, CacheBackendInterface $cache_backend, ModuleHandlerInterface $module_handler) { public function __construct(\Traversable $namespaces, CacheBackendInterface $cache_backend, ModuleHandlerInterface $module_handler) {
parent::__construct('Plugin/UiPatternsMappingSource', $namespaces, $module_handler, 'Drupal\ui_patterns\Plugin\UiPatternsMappingSourceInterface', 'Drupal\ui_patterns\Annotation\UiPatternsMappingSource'); parent::__construct('Plugin/UiPatterns/Source', $namespaces, $module_handler, 'Drupal\ui_patterns\Plugin\UiPatternsSourceInterface', 'Drupal\ui_patterns\Annotation\UiPatternsSource');
$this->alterInfo('ui_patterns_mapping_source_info'); $this->alterInfo('ui_patterns_ui_patterns_source_info');
$this->setCacheBackend($cache_backend, 'ui_patterns_ui_patterns_mapping_source_plugins'); $this->setCacheBackend($cache_backend, 'ui_patterns_ui_patterns_source_plugins');
} }
} }
...@@ -10,10 +10,10 @@ function hook_ui_patterns_info_alter(&$definitions) { ...@@ -10,10 +10,10 @@ function hook_ui_patterns_info_alter(&$definitions) {
} }
/** /**
* Alter UI Patterns Mapping Source definitions. * Alter UI Patterns Source definitions.
* *
* @see \Drupal\ui_patterns\Plugin\UiPatternsMappingSourceManager * @see \Drupal\ui_patterns\Plugin\UiPatternsSourceManager
*/ */
function hook_ui_patterns_mapping_source_info_alter(&$definitions) { function hook_ui_patterns_ui_patterns_source_info_alter(&$definitions) {
} }
...@@ -2,6 +2,6 @@ services: ...@@ -2,6 +2,6 @@ services:
plugin.manager.ui_patterns: plugin.manager.ui_patterns:
class: Drupal\ui_patterns\UiPatternsManager class: Drupal\ui_patterns\UiPatternsManager
arguments: ['@module_handler', '@theme_handler', '@theme.manager', '@cache.discovery'] arguments: ['@module_handler', '@theme_handler', '@theme.manager', '@cache.discovery']
plugin.manager.ui_patterns_mapping_source: plugin.manager.ui_patterns_source:
class: Drupal\ui_patterns\Plugin\UiPatternsMappingSourceManager class: Drupal\ui_patterns\Plugin\UiPatternsSourceManager
parent: default_plugin_manager parent: default_plugin_manager
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment