Initial Drupal 11 with DDEV setup
This commit is contained in:
9
vendor/chi-teck/drupal-code-generator/templates/_plugin-manager/yaml/model.examples.yml.twig
vendored
Normal file
9
vendor/chi-teck/drupal-code-generator/templates/_plugin-manager/yaml/model.examples.yml.twig
vendored
Normal file
@ -0,0 +1,9 @@
|
||||
{{ machine_name }}.example_1:
|
||||
label: 'Example 1'
|
||||
description: 'Plugin description.'
|
||||
{{ machine_name }}.example_2:
|
||||
label: 'Example 2'
|
||||
description: 'Plugin description.'
|
||||
{{ machine_name }}.example_3:
|
||||
label: 'Example 3'
|
||||
description: 'Plugin description.'
|
||||
4
vendor/chi-teck/drupal-code-generator/templates/_plugin-manager/yaml/model.services.yml.twig
vendored
Normal file
4
vendor/chi-teck/drupal-code-generator/templates/_plugin-manager/yaml/model.services.yml.twig
vendored
Normal file
@ -0,0 +1,4 @@
|
||||
services:
|
||||
plugin.manager.{{ plugin_type }}:
|
||||
class: Drupal\{{ machine_name }}\{{ class_prefix }}PluginManager
|
||||
arguments: ['@module_handler', '@cache.discovery']
|
||||
22
vendor/chi-teck/drupal-code-generator/templates/_plugin-manager/yaml/src/ExampleDefault.php.twig
vendored
Normal file
22
vendor/chi-teck/drupal-code-generator/templates/_plugin-manager/yaml/src/ExampleDefault.php.twig
vendored
Normal file
@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Drupal\{{ machine_name }};
|
||||
|
||||
use Drupal\Core\Plugin\PluginBase;
|
||||
|
||||
/**
|
||||
* Default class used for {{ plugin_type|pluralize }} plugins.
|
||||
*/
|
||||
final class {{ class_prefix }}Default extends PluginBase implements {{ class_prefix }}Interface {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function label(): string {
|
||||
// The title from YAML file discovery may be a TranslatableMarkup object.
|
||||
return (string) $this->pluginDefinition['label'];
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Drupal\{{ machine_name }};
|
||||
|
||||
/**
|
||||
* Interface for {{ plugin_type }} plugins.
|
||||
*/
|
||||
interface {{ class_prefix }}Interface {
|
||||
|
||||
/**
|
||||
* Returns the translated plugin label.
|
||||
*/
|
||||
public function label(): string;
|
||||
|
||||
}
|
||||
@ -0,0 +1,66 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Drupal\{{ machine_name }};
|
||||
|
||||
use Drupal\Core\Cache\CacheBackendInterface;
|
||||
use Drupal\Core\Extension\ModuleHandlerInterface;
|
||||
use Drupal\Core\Plugin\DefaultPluginManager;
|
||||
use Drupal\Core\Plugin\Discovery\YamlDiscovery;
|
||||
use Drupal\Core\Plugin\Factory\ContainerFactory;
|
||||
|
||||
/**
|
||||
* Defines a plugin manager to deal with {{ plugin_type|pluralize }}.
|
||||
*
|
||||
* Modules can define {{ plugin_type|pluralize }} in a MODULE_NAME.{{ plugin_type|pluralize }}.yml file contained
|
||||
* in the module's base directory. Each {{ plugin_type }} has the following structure:
|
||||
*
|
||||
* @code
|
||||
* MACHINE_NAME:
|
||||
* label: STRING
|
||||
* description: STRING
|
||||
* @endcode
|
||||
*
|
||||
* @see \Drupal\{{ machine_name }}\{{ class_prefix }}Default
|
||||
* @see \Drupal\{{ machine_name }}\{{ class_prefix }}Interface
|
||||
*/
|
||||
final class {{ class_prefix }}PluginManager extends DefaultPluginManager {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected $defaults = [
|
||||
// The {{ plugin_type }} id. Set by the plugin system based on the top-level YAML key.
|
||||
'id' => '',
|
||||
// The {{ plugin_type }} label.
|
||||
'label' => '',
|
||||
// The {{ plugin_type }} description.
|
||||
'description' => '',
|
||||
// Default plugin class.
|
||||
'class' => {{ class_prefix }}Default::class,
|
||||
];
|
||||
|
||||
/**
|
||||
* Constructs {{ class_prefix }}PluginManager object.
|
||||
*/
|
||||
public function __construct(ModuleHandlerInterface $module_handler, CacheBackendInterface $cache_backend) {
|
||||
$this->factory = new ContainerFactory($this);
|
||||
$this->moduleHandler = $module_handler;
|
||||
$this->alterInfo('{{ plugin_type }}_info');
|
||||
$this->setCacheBackend($cache_backend, '{{ plugin_type }}_plugins');
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function getDiscovery(): YamlDiscovery {
|
||||
if (!isset($this->discovery)) {
|
||||
$this->discovery = new YamlDiscovery('{{ plugin_type|pluralize }}', $this->moduleHandler->getModuleDirectories());
|
||||
$this->discovery->addTranslatableProperty('label', 'label_context');
|
||||
$this->discovery->addTranslatableProperty('description', 'description_context');
|
||||
}
|
||||
return $this->discovery;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user