Update Composer, update everything

This commit is contained in:
Oliver Davies 2018-11-23 12:29:20 +00:00
parent ea3e94409f
commit dda5c284b6
19527 changed files with 1135420 additions and 351004 deletions

View file

@ -0,0 +1,4 @@
services:
plugin.manager.{{ plugin_type }}:
class: Drupal\{{ machine_name }}\{{ class_prefix }}PluginManager
parent: default_plugin_manager

View file

@ -0,0 +1,39 @@
<?php
namespace Drupal\{{ machine_name }}\Annotation;
use Drupal\Component\Annotation\Plugin;
/**
* Defines {{ plugin_type }} annotation object.
*
* @Annotation
*/
class {{ class_prefix }} extends Plugin {
/**
* The plugin ID.
*
* @var string
*/
public $id;
/**
* The human-readable name of the plugin.
*
* @var \Drupal\Core\Annotation\Translation
*
* @ingroup plugin_translatable
*/
public $title;
/**
* The description of the plugin.
*
* @var \Drupal\Core\Annotation\Translation
*
* @ingroup plugin_translatable
*/
public $description;
}

View file

@ -0,0 +1,18 @@
<?php
namespace Drupal\{{ machine_name }};
/**
* Interface for {{ plugin_type }} plugins.
*/
interface {{ class_prefix }}Interface {
/**
* Returns the translated plugin label.
*
* @return string
* The translated title.
*/
public function label();
}

View file

@ -0,0 +1,20 @@
<?php
namespace Drupal\{{ machine_name }};
use Drupal\Component\Plugin\PluginBase;
/**
* Base class for {{ plugin_type }} plugins.
*/
abstract class {{ class_prefix }}PluginBase extends PluginBase implements {{ class_prefix }}Interface {
/**
* {@inheritdoc}
*/
public function label() {
// Cast the label to a string since it is a TranslatableMarkup object.
return (string) $this->pluginDefinition['label'];
}
}

View file

@ -0,0 +1,37 @@
<?php
namespace Drupal\{{ machine_name }};
use Drupal\Core\Cache\CacheBackendInterface;
use Drupal\Core\Extension\ModuleHandlerInterface;
use Drupal\Core\Plugin\DefaultPluginManager;
/**
* {{ class_prefix }} plugin manager.
*/
class {{ class_prefix }}PluginManager extends DefaultPluginManager {
/**
* Constructs {{ class_prefix }}PluginManager object.
*
* @param \Traversable $namespaces
* An object that implements \Traversable which contains the root paths
* keyed by the corresponding namespace to look for plugin implementations.
* @param \Drupal\Core\Cache\CacheBackendInterface $cache_backend
* Cache backend instance to use.
* @param \Drupal\Core\Extension\ModuleHandlerInterface $module_handler
* The module handler to invoke the alter hook with.
*/
public function __construct(\Traversable $namespaces, CacheBackendInterface $cache_backend, ModuleHandlerInterface $module_handler) {
parent::__construct(
'Plugin/{{ class_prefix }}',
$namespaces,
$module_handler,
'Drupal\{{ machine_name }}\{{ class_prefix }}Interface',
'Drupal\{{ machine_name }}\Annotation\{{ class_prefix }}'
);
$this->alterInfo('{{ plugin_type }}_info');
$this->setCacheBackend($cache_backend, '{{ plugin_type }}_plugins');
}
}

View file

@ -0,0 +1,18 @@
<?php
namespace Drupal\{{ machine_name }}\Plugin\{{ class_prefix }};
use Drupal\{{ machine_name }}\{{ class_prefix }}PluginBase;
/**
* Plugin implementation of the {{ plugin_type }}.
*
* @{{ class_prefix }}(
* id = "foo",
* label = @Translation("Foo"),
* description = @Translation("Foo description.")
* )
*/
class Foo extends {{ class_prefix }}PluginBase {
}

View file

@ -0,0 +1,17 @@
/**
* Implements hook_{{ plugin_type }}_info().
*/
function {{ machine_name }}_{{ plugin_type }}_info() {
return [
'foo' => [
'id' => 'foo',
'label' => t('Foo'),
'description' => t('Foo description.'),
],
'bar' => [
'id' => 'bar',
'label' => t('Bar'),
'description' => t('Bar description.'),
],
];
}

View file

@ -0,0 +1,4 @@
services:
plugin.manager.{{ plugin_type }}:
class: Drupal\{{ machine_name }}\{{ class_prefix }}PluginManager
arguments: ['@module_handler', '@cache.discovery']

View file

@ -0,0 +1,20 @@
<?php
namespace Drupal\{{ machine_name }};
use Drupal\Core\Plugin\PluginBase;
/**
* Default class used for {{ plugin_type|plural }} plugins.
*/
class {{ class_prefix }}Default extends PluginBase implements {{ class_prefix }}Interface {
/**
* {@inheritdoc}
*/
public function label() {
// The title from hook discovery may be a TranslatableMarkup object.
return (string) $this->pluginDefinition['label'];
}
}

View file

@ -0,0 +1,18 @@
<?php
namespace Drupal\{{ machine_name }};
/**
* Interface for {{ plugin_type }} plugins.
*/
interface {{ class_prefix }}Interface {
/**
* Returns the translated plugin label.
*
* @return string
* The translated title.
*/
public function label();
}

View file

@ -0,0 +1,59 @@
<?php
namespace Drupal\{{ machine_name }};
use Drupal\Core\Cache\CacheBackendInterface;
use Drupal\Core\Extension\ModuleHandlerInterface;
use Drupal\Core\Plugin\DefaultPluginManager;
use Drupal\Core\Plugin\Discovery\HookDiscovery;
use Drupal\Core\Plugin\Factory\ContainerFactory;
/**
* Defines a plugin manager to deal with {{ plugin_type|plural }}.
*
* @see \Drupal\{{ machine_name }}\{{ class_prefix }}Default
* @see \Drupal\{{ machine_name }}\{{ class_prefix }}Interface
* @see plugin_api
*/
class {{ class_prefix }}PluginManager extends DefaultPluginManager {
/**
* {@inheritdoc}
*/
protected $defaults = [
// The {{ plugin_type }} id. Set by the plugin system based on the array key.
'id' => '',
// The {{ plugin_type }} label.
'label' => '',
// The {{ plugin_type }} description.
'description' => '',
// Default plugin class.
'class' => 'Drupal\{{ machine_name }}\{{ class_prefix }}Default',
];
/**
* Constructs {{ class_prefix }}PluginManager object.
*
* @param \Drupal\Core\Extension\ModuleHandlerInterface $module_handler
* The module handler to invoke the alter hook with.
* @param \Drupal\Core\Cache\CacheBackendInterface $cache_backend
* Cache backend instance to use.
*/
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() {
if (!isset($this->discovery)) {
$this->discovery = new HookDiscovery($this->moduleHandler, '{{ plugin_type }}_info');
}
return $this->discovery;
}
}

View file

@ -0,0 +1,9 @@
foo_1:
label: 'Foo 1'
description: 'Plugin description.'
foo_2:
label: 'Foo 2'
description: 'Plugin description.'
foo_3:
label: 'Foo 3'
description: 'Plugin description.'

View file

@ -0,0 +1,4 @@
services:
plugin.manager.{{ plugin_type }}:
class: Drupal\{{ machine_name }}\{{ class_prefix }}PluginManager
arguments: ['@module_handler', '@cache.discovery']

View file

@ -0,0 +1,20 @@
<?php
namespace Drupal\{{ machine_name }};
use Drupal\Core\Plugin\PluginBase;
/**
* Default class used for {{ plugin_type|plural }} plugins.
*/
class {{ class_prefix }}Default extends PluginBase implements {{ class_prefix }}Interface {
/**
* {@inheritdoc}
*/
public function label() {
// The title from YAML file discovery may be a TranslatableMarkup object.
return (string) $this->pluginDefinition['label'];
}
}

View file

@ -0,0 +1,18 @@
<?php
namespace Drupal\{{ machine_name }};
/**
* Interface for {{ plugin_type }} plugins.
*/
interface {{ class_prefix }}Interface {
/**
* Returns the translated plugin label.
*
* @return string
* The translated title.
*/
public function label();
}

View file

@ -0,0 +1,70 @@
<?php
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|plural }}.
*
* Modules can define {{ plugin_type|plural }} in a MODULE_NAME.{{ plugin_type|plural }}.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
* @see plugin_api
*/
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' => 'Drupal\{{ machine_name }}\{{ class_prefix }}Default',
];
/**
* Constructs {{ class_prefix }}PluginManager object.
*
* @param \Drupal\Core\Extension\ModuleHandlerInterface $module_handler
* The module handler to invoke the alter hook with.
* @param \Drupal\Core\Cache\CacheBackendInterface $cache_backend
* Cache backend instance to use.
*/
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() {
if (!isset($this->discovery)) {
$this->discovery = new YamlDiscovery('{{ plugin_type|plural }}', $this->moduleHandler->getModuleDirectories());
$this->discovery->addTranslatableProperty('label', 'label_context');
$this->discovery->addTranslatableProperty('description', 'description_context');
}
return $this->discovery;
}
}