Loading modules/tax/records_tax.services.yml 0 → 100644 +5 −0 Original line number Diff line number Diff line services: # Plugin managers. plugin.manager.records_tax_form_configurator: class: Drupal\records_tax\EntityConfigurator\Form\PluginManager parent: default_plugin_manager modules/tax/src/Annotation/RecordsTaxFormEntityConfigurator.php 0 → 100644 +48 −0 Original line number Diff line number Diff line <?php namespace Drupal\records_tax\Annotation; use Drupal\Component\Annotation\Plugin; /** * The annotation object for the tax form configurator plugins. * * Plugin namespace: Plugin\Records\EntityConfigurator\TaxForm. * * @Annotation */ class RecordsTaxFormEntityConfigurator extends Plugin { /** * The plugin ID. * * @var string */ public $id; /** * The human-readable label of the plugin. * * @var \Drupal\Core\Annotation\Translation * * @ingroup plugin_translatable */ public $label; /** * A short description of the plugin. * * @var \Drupal\Core\Annotation\Translation * * @ingroup plugin_translatable */ public $description; /** * The workflow ID for the tax form state field. * * @var string */ public $workflow_id; } modules/tax/src/EntityConfigurator/Form/PluginBase.php 0 → 100644 +39 −0 Original line number Diff line number Diff line <?php namespace Drupal\records_tax\EntityConfigurator\Form; use Drupal\records\EntityConfigurator\Records\Plugin\PluginBase as ConfiguratorPluginBase; use Drupal\records\Exception\InvalidConfigurationException; /** * Default base class for tax form configurator plugin implementations. */ abstract class PluginBase extends ConfiguratorPluginBase implements PluginInterface { /** * Constructs a new PluginBase object. * * @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 ) { parent::__construct($configuration, $plugin_id, $plugin_definition); if (!isset($plugin_definition['workflow_id'])) { throw new InvalidConfigurationException(sprintf( 'No workflow defined by plugin with ID "%s".', $plugin_id )); } } } modules/tax/src/EntityConfigurator/Form/PluginInterface.php 0 → 100644 +17 −0 Original line number Diff line number Diff line <?php namespace Drupal\records_tax\EntityConfigurator\Form; use Drupal\records\EntityConfigurator\Records\Plugin\PluginInterface as ConfiguratorPluginInterface; /** * Provides the interface for tax form configurator plugins. * * Tax form configurator plugins are responsible for configuring the behavior * of tax form types. That includes the following: * * - Generates the tax form title, if needed. * - Calculates any computed fields, if needed. * - Provides any fields required by the plugin. */ interface PluginInterface extends ConfiguratorPluginInterface {} modules/tax/src/EntityConfigurator/Form/PluginManager.php 0 → 100644 +47 −0 Original line number Diff line number Diff line <?php namespace Drupal\records_tax\EntityConfigurator\Form; use Drupal\records\EntityConfigurator\Records\Plugin\PluginManagerBase; use Drupal\records_tax\Annotation\RecordsTaxFormEntityConfigurator as PluginAnnotation; use Drupal\Core\Cache\CacheBackendInterface; use Drupal\Core\Extension\ModuleHandlerInterface; /** * The default plugin manager for tax form configurator plugins. */ class PluginManager extends PluginManagerBase { /** * Constructs a new 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/Records/EntityConfigurator/TaxForm', $namespaces, $module_handler, PluginInterface::class, PluginAnnotation::class ); $this->alterInfo('records_tax_form_configurator_info'); $this->setCacheBackend( $cache_backend, 'records_tax_form_configurator', ['records_tax_form_configurator_plugins'] ); } } Loading
modules/tax/records_tax.services.yml 0 → 100644 +5 −0 Original line number Diff line number Diff line services: # Plugin managers. plugin.manager.records_tax_form_configurator: class: Drupal\records_tax\EntityConfigurator\Form\PluginManager parent: default_plugin_manager
modules/tax/src/Annotation/RecordsTaxFormEntityConfigurator.php 0 → 100644 +48 −0 Original line number Diff line number Diff line <?php namespace Drupal\records_tax\Annotation; use Drupal\Component\Annotation\Plugin; /** * The annotation object for the tax form configurator plugins. * * Plugin namespace: Plugin\Records\EntityConfigurator\TaxForm. * * @Annotation */ class RecordsTaxFormEntityConfigurator extends Plugin { /** * The plugin ID. * * @var string */ public $id; /** * The human-readable label of the plugin. * * @var \Drupal\Core\Annotation\Translation * * @ingroup plugin_translatable */ public $label; /** * A short description of the plugin. * * @var \Drupal\Core\Annotation\Translation * * @ingroup plugin_translatable */ public $description; /** * The workflow ID for the tax form state field. * * @var string */ public $workflow_id; }
modules/tax/src/EntityConfigurator/Form/PluginBase.php 0 → 100644 +39 −0 Original line number Diff line number Diff line <?php namespace Drupal\records_tax\EntityConfigurator\Form; use Drupal\records\EntityConfigurator\Records\Plugin\PluginBase as ConfiguratorPluginBase; use Drupal\records\Exception\InvalidConfigurationException; /** * Default base class for tax form configurator plugin implementations. */ abstract class PluginBase extends ConfiguratorPluginBase implements PluginInterface { /** * Constructs a new PluginBase object. * * @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 ) { parent::__construct($configuration, $plugin_id, $plugin_definition); if (!isset($plugin_definition['workflow_id'])) { throw new InvalidConfigurationException(sprintf( 'No workflow defined by plugin with ID "%s".', $plugin_id )); } } }
modules/tax/src/EntityConfigurator/Form/PluginInterface.php 0 → 100644 +17 −0 Original line number Diff line number Diff line <?php namespace Drupal\records_tax\EntityConfigurator\Form; use Drupal\records\EntityConfigurator\Records\Plugin\PluginInterface as ConfiguratorPluginInterface; /** * Provides the interface for tax form configurator plugins. * * Tax form configurator plugins are responsible for configuring the behavior * of tax form types. That includes the following: * * - Generates the tax form title, if needed. * - Calculates any computed fields, if needed. * - Provides any fields required by the plugin. */ interface PluginInterface extends ConfiguratorPluginInterface {}
modules/tax/src/EntityConfigurator/Form/PluginManager.php 0 → 100644 +47 −0 Original line number Diff line number Diff line <?php namespace Drupal\records_tax\EntityConfigurator\Form; use Drupal\records\EntityConfigurator\Records\Plugin\PluginManagerBase; use Drupal\records_tax\Annotation\RecordsTaxFormEntityConfigurator as PluginAnnotation; use Drupal\Core\Cache\CacheBackendInterface; use Drupal\Core\Extension\ModuleHandlerInterface; /** * The default plugin manager for tax form configurator plugins. */ class PluginManager extends PluginManagerBase { /** * Constructs a new 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/Records/EntityConfigurator/TaxForm', $namespaces, $module_handler, PluginInterface::class, PluginAnnotation::class ); $this->alterInfo('records_tax_form_configurator_info'); $this->setCacheBackend( $cache_backend, 'records_tax_form_configurator', ['records_tax_form_configurator_plugins'] ); } }