fieldry-1.0.x-dev/src/Plugin/WrapperInterface.php
src/Plugin/WrapperInterface.php
<?php
namespace Drupal\fieldry\Plugin;
use Drupal\Component\Plugin\PluginInspectionInterface;
use Drupal\Component\Plugin\ConfigurableInterface;
use Drupal\Core\Field\FormatterInterface;
use Drupal\Core\Field\FieldDefinitionInterface;
use Drupal\Core\Field\FieldItemListInterface;
/**
* Interface for defining various field wrapper options.
*
* Field wrappers the additional DIV tags that surround entity fields and are
* provided by the field theme template. Field wrappers allow per field
* manipulation of common field wrappers.
*/
interface WrapperInterface extends PluginInspectionInterface, ConfigurableInterface {
/**
* Does this field wrapper apply to the field formatter and field?
*
* @param mixed $plugin_definition
* The plugin definition from the fieldry wrapper plugin manager.
* @param \Drupal\Core\Field\FormatterInterface $formatter
* The field formatter the settings are for.
* @param \Drupal\Core\Field\FieldDefinitionInterface $field_definition
* The field definition of the field the display settings are targeting.
*
* @return bool
* Should this field formatter be allowed for this field and field
* formatter? TRUE if the wrapper should be allowed as an option.
*/
public static function isApplicable($plugin_definition, FormatterInterface $formatter, FieldDefinitionInterface $field_definition): bool;
/**
* Generate the field content to be inside of the field wrapper.
*
* @param array $element
* The render element to alter and generate the field wrapped content from.
* @param \Drupal\Core\Field\FieldItemListInterface $items
* The field items which are being wrapped by this field wrapper.
* @param array $variables
* Reference to theme $variables from process and preprocess hooks.
*/
public function preprocess(array $element, FieldItemListInterface $items, array &$variables): void;
/**
* Get theme suggestions to add to the field for theme selection.
*
* @param array $suggestions
* Array of theme suggestions to alter.
* @param array $variables
* Field theme variables and context information.
*/
public function themeSuggestions(array &$suggestions, array $variables): void;
}
