Skip to content
Snippets Groups Projects
Commit 65e352de authored by Kevin Kaland's avatar Kevin Kaland
Browse files

Issue #2359213: Add fillpdf_action plugin.

parent 486cb561
No related branches found
No related tags found
No related merge requests found
......@@ -16,3 +16,7 @@ services:
fillpdf.context_manager:
class: Drupal\fillpdf\Service\FillPdfContextManager
arguments: ['@entity.manager']
plugin.manager.fillpdf_action.processor:
class: Drupal\fillpdf\Plugin\FillPdfActionPluginManager
parent: default_plugin_manager
<?php
/**
* @file
* Contains Drupal\fillpdf\Annotation\FillPdfActionPlugin.
*/
namespace Drupal\fillpdf\Annotation;
use Drupal\Component\Annotation\Plugin;
/**
* Defines a FillPDF action plugin item annotation object.
*
* @see \Drupal\fillpdf\Plugin\FillPdfActionPluginManager
* @see plugin_api
*
* @Annotation
*/
class FillPdfActionPlugin extends Plugin {
/**
* The plugin ID.
*
* @var string
*/
public $id;
/**
* The label of the plugin.
*
* @var \Drupal\Core\Annotation\Translation
*
* @ingroup plugin_translatable
*/
public $label;
}
<?php
/**
* @file
* Contains Drupal\fillpdf\Plugin\FillPdfActionPluginBase.
*/
namespace Drupal\fillpdf\Plugin;
use Drupal\Component\Plugin\PluginBase;
/**
* Base class for FillPDF action plugin plugins.
*/
abstract class FillPdfActionPluginBase extends PluginBase implements FillPdfActionPluginInterface {
// Add common methods and abstract methods for your plugin type here.
}
<?php
/**
* @file
* Contains Drupal\fillpdf\Plugin\FillPdfActionPluginInterface.
*/
namespace Drupal\fillpdf\Plugin;
use Drupal\Component\Plugin\PluginInspectionInterface;
use Symfony\Component\HttpFoundation\Response;
/**
* Defines an interface for FillPDF action plugins.
*
* Action plugins should ultimately return a
* \Symfony\Component\HttpFoundation\Response. They may provide additional
* methods to provide callers with additional plugin-specific metadata.
*/
interface FillPdfActionPluginInterface extends PluginInspectionInterface {
/**
* Take action according to the plugin configuration. This will vary for each
* action plugin, but it should do something with the PDF (e.g. prepare a
* download response, save it to a file, etc.) and return an appropriate
* Response (or subclass thereof) to the caller.
*
* @return Response
* @todo Document exceptions thrown if something goes wrong.
*/
public function execute();
}
<?php
/**
* @file
* Contains Drupal\fillpdf\Plugin\FillPdfActionPluginManager.
*/
namespace Drupal\fillpdf\Plugin;
use Drupal\Core\Plugin\DefaultPluginManager;
use Drupal\Core\Cache\CacheBackendInterface;
use Drupal\Core\Extension\ModuleHandlerInterface;
/**
* Provides the FillPDF action plugin plugin manager.
*/
class FillPdfActionPluginManager extends DefaultPluginManager {
/**
* Constructor for FillPdfActionPluginManager objects.
*
* @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/FillPdfActionPlugin', $namespaces, $module_handler, 'Drupal\fillpdf\Plugin\FillPdfActionPluginInterface', 'Drupal\fillpdf\Annotation\FillPdfActionPlugin');
$this->alterInfo('fillpdf_fillpdf_action_info');
$this->setCacheBackend($cache_backend, 'fillpdf_fillpdf_action_plugins');
}
}
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