interface FieldHandlerInterface

Same name in other branches
  1. 9 core/modules/views/src/Plugin/views/field/FieldHandlerInterface.php \Drupal\views\Plugin\views\field\FieldHandlerInterface
  2. 8.9.x core/modules/views/src/Plugin/views/field/FieldHandlerInterface.php \Drupal\views\Plugin\views\field\FieldHandlerInterface
  3. 10 core/modules/views/src/Plugin/views/field/FieldHandlerInterface.php \Drupal\views\Plugin\views\field\FieldHandlerInterface

Base field handler that has no options and renders an unformatted field.

Hierarchy

Expanded class hierarchy of FieldHandlerInterface

All classes that implement FieldHandlerInterface

File

core/modules/views/src/Plugin/views/field/FieldHandlerInterface.php, line 11

Namespace

Drupal\views\Plugin\views\field
View source
interface FieldHandlerInterface extends ViewsHandlerInterface {
    
    /**
     * Adds an ORDER BY clause to the query for click sort columns.
     *
     * @param string $order
     *   The sort order, either 'ASC' or 'DESC'.
     */
    public function clickSort($order);
    
    /**
     * Determines if this field is click sortable.
     *
     * @return bool
     *   The value of 'click sortable' from the plugin definition, this defaults
     *   to TRUE if not set.
     */
    public function clickSortable();
    
    /**
     * Gets this field's label.
     */
    public function label();
    
    /**
     * Returns an HTML element based upon the field's element type.
     *
     * @param bool $none_supported
     *   (optional) Whether or not this HTML element is supported. Defaults to
     *   FALSE.
     * @param bool $default_empty
     *   (optional) Whether or not this HTML element is empty by default. Defaults
     *   to FALSE.
     * @param bool $inline
     *   (optional) Whether or not this HTML element is inline. Defaults to FALSE.
     */
    public function elementType($none_supported = FALSE, $default_empty = FALSE, $inline = FALSE);
    
    /**
     * Returns an HTML element for the label based upon the field's element type.
     *
     * @param bool $none_supported
     *   (optional) Whether or not this HTML element is supported. Defaults to
     *   FALSE.
     * @param bool $default_empty
     *   (optional) Whether or not this HTML element is empty by default. Defaults
     *   to FALSE.
     */
    public function elementLabelType($none_supported = FALSE, $default_empty = FALSE);
    
    /**
     * Returns a wrapper HTML element for the field..
     *
     * @param bool $none_supported
     *   (optional) Whether or not this HTML element is supported. Defaults to
     *   FALSE.
     * @param bool $default_empty
     *   (optional) Whether or not this HTML element is empty by default. Defaults
     *   to FALSE.
     */
    public function elementWrapperType($none_supported = FALSE, $default_empty = FALSE);
    
    /**
     * Provides a list of elements valid for field HTML.
     *
     * This function can be overridden by fields that want more or fewer elements
     * available, though this seems like it would be an incredibly rare
     * occurrence.
     */
    public function getElements();
    
    /**
     * Returns the class of the field.
     *
     * @param int|null $row_index
     *   (optional) Index of the row element. If NULL the last row is used.
     *   Defaults to NULL.
     */
    public function elementClasses($row_index = NULL);
    
    /**
     * Replaces a value with tokens from the last field.
     *
     * This function actually figures out which field was last and uses its
     * tokens so they will all be available.
     *
     * @param string $value
     *   The raw string.
     * @param int|null $row_index
     *   (optional) Index of the row element. If NULL the last row is used.
     *   Defaults to NULL.
     */
    public function tokenizeValue($value, $row_index = NULL);
    
    /**
     * Returns the class of the field's label.
     *
     * @param int|null $row_index
     *   (optional) Index of the row element. If NULL the last row is used.
     *   Defaults to NULL.
     */
    public function elementLabelClasses($row_index = NULL);
    
    /**
     * Returns the class of the field's wrapper.
     *
     * @param int|null $row_index
     *   (optional) Index of the row element. If NULL the last row is used.
     *   Defaults to NULL.
     */
    public function elementWrapperClasses($row_index = NULL);
    
    /**
     * Gets the entity matching the current row and relationship.
     *
     * @param \Drupal\views\ResultRow $values
     *   An object containing all retrieved values.
     *
     * @return \Drupal\Core\Entity\EntityInterface|null
     *   Returns the entity matching the values or NULL if there is no matching
     *   entity.
     */
    public function getEntity(ResultRow $values);
    
    /**
     * Gets the value that's supposed to be rendered.
     *
     * This api exists so that other modules can easy set the values of the field
     * without having the need to change the render method as well.
     *
     * @param \Drupal\views\ResultRow $values
     *   An object containing all retrieved values.
     * @param string|null $field
     *   (optional) Index of the row element. If NULL the last row is used.
     *   Defaults to NULL.
     *
     * @return mixed
     *   The value to be rendered.
     */
    public function getValue(ResultRow $values, $field = NULL);
    
    /**
     * Determines if this field can be grouped in the results.
     *
     * @return bool
     *   TRUE if this field handler is groupable, otherwise FALSE.
     */
    public function useStringGroupBy();
    
    /**
     * Runs before any fields are rendered.
     *
     * This gives the handlers some time to set up before any handler has been
     * rendered.
     *
     * @param \Drupal\views\ResultRow[] $values
     *   An array of all ResultRow objects returned from the query.
     */
    public function preRender(&$values);
    
    /**
     * Renders the field.
     *
     * @param \Drupal\views\ResultRow $values
     *   The values retrieved from a single row of a view's query result.
     *
     * @return string|\Drupal\Component\Render\MarkupInterface
     *   The rendered output. If the output is safe it will be wrapped in an
     *   object that implements MarkupInterface. If it is empty or unsafe it
     *   will be a string.
     */
    public function render(ResultRow $values);
    
    /**
     * Runs after every field has been rendered.
     *
     * This is meant to be used mainly to deal with field handlers whose output
     * cannot be cached at row level but can be cached at display level. The
     * typical example is the row counter. For completely uncacheable field output
     * placeholders should be used.
     *
     * @param \Drupal\views\ResultRow $row
     *   An array of all ResultRow objects returned from the query.
     * @param $output
     *   The field rendered output.
     *
     * @return string[]
     *   An associative array of post-render token values keyed by placeholder.
     *
     * @see \Drupal\views\Plugin\views\field\UncacheableFieldHandlerTrait
     */
    public function postRender(ResultRow $row, $output);
    
    /**
     * Renders a field using advanced settings.
     *
     * This renders a field normally, then decides if render-as-link and
     * text-replacement rendering is necessary.
     *
     * @param \Drupal\views\ResultRow $values
     *   The values retrieved from a single row of a view's query result.
     *
     * @return \Drupal\Component\Render\MarkupInterface|string
     *   The advanced rendered output. If the output is safe, it will be wrapped
     *   in an object that implements MarkupInterface. If it is empty or unsafe,
     *   it will be a string.
     */
    public function advancedRender(ResultRow $values);
    
    /**
     * Checks if a field value is empty.
     *
     * @param $value
     *   The field value.
     * @param bool $empty_zero
     *   Whether or not this field is configured to consider 0 as empty.
     * @param bool $no_skip_empty
     *   (optional) Whether or not to use empty() to check the value. Defaults to
     *   TRUE.
     *
     * @return bool
     *   TRUE if the value is considered empty, FALSE otherwise.
     */
    public function isValueEmpty($value, $empty_zero, $no_skip_empty = TRUE);
    
    /**
     * Performs an advanced text render for the item.
     *
     * This is separated out as some fields may render lists, and this allows each
     * item to be handled individually.
     *
     * @param array $alter
     *   The alter array of options to use:
     *   - max_length: Maximum length of a string, the rest gets truncated.
     *   - word_boundary: Trim only on a word boundary.
     *   - ellipsis: Show an ellipsis at the end of the trimmed string.
     *   - html: Make sure that the HTML is correct.
     *
     * @return \Drupal\Component\Render\MarkupInterface|string
     *   The rendered output. If the output is safe it will be wrapped in an
     *   object that implements MarkupInterface. If it is empty or unsafe it will
     *   be a string.
     */
    public function renderText($alter);
    
    /**
     * Gets the 'render' tokens to use for advanced rendering.
     *
     * This runs through all of the fields and arguments that are available and
     * gets their values. This will then be used in one giant str_replace().
     *
     * @param mixed $item
     *   The item to render.
     *
     * @return array
     *   An array of available tokens
     */
    public function getRenderTokens($item);
    
    /**
     * Renders row values using $this->themeFunctions() as #theme.
     *
     * @param \Drupal\views\ResultRow $values
     *   Holds single row of a view's result set.
     *
     * @return \Drupal\Component\Render\MarkupInterface|string
     *   Returns rendered output of the given theme implementation. If the output
     *   is safe, it will be wrapped in an object that implements MarkupInterface.
     *   If it is empty or unsafe, it will be a string.
     */
    public function theme(ResultRow $values);

}

Members

Title Sort descending Modifiers Object type Summary Overrides
ContainerFactoryPluginInterface::create public static function Creates an instance of the plugin. 136
DerivativeInspectionInterface::getBaseId public function Gets the base_plugin_id of the plugin instance. 1
DerivativeInspectionInterface::getDerivativeId public function Gets the derivative_id of the plugin instance. 1
FieldHandlerInterface::advancedRender public function Renders a field using advanced settings. 1
FieldHandlerInterface::clickSort public function Adds an ORDER BY clause to the query for click sort columns. 1
FieldHandlerInterface::clickSortable public function Determines if this field is click sortable. 1
FieldHandlerInterface::elementClasses public function Returns the class of the field. 1
FieldHandlerInterface::elementLabelClasses public function Returns the class of the field's label. 1
FieldHandlerInterface::elementLabelType public function Returns an HTML element for the label based upon the field's element type. 1
FieldHandlerInterface::elementType public function Returns an HTML element based upon the field's element type. 1
FieldHandlerInterface::elementWrapperClasses public function Returns the class of the field's wrapper. 1
FieldHandlerInterface::elementWrapperType public function Returns a wrapper HTML element for the field.. 1
FieldHandlerInterface::getElements public function Provides a list of elements valid for field HTML. 1
FieldHandlerInterface::getEntity public function Gets the entity matching the current row and relationship. 1
FieldHandlerInterface::getRenderTokens public function Gets the 'render' tokens to use for advanced rendering. 1
FieldHandlerInterface::getValue public function Gets the value that's supposed to be rendered. 1
FieldHandlerInterface::isValueEmpty public function Checks if a field value is empty. 1
FieldHandlerInterface::label public function Gets this field's label. 1
FieldHandlerInterface::postRender public function Runs after every field has been rendered. 1
FieldHandlerInterface::preRender public function Runs before any fields are rendered. 1
FieldHandlerInterface::render public function Renders the field. 1
FieldHandlerInterface::renderText public function Performs an advanced text render for the item. 1
FieldHandlerInterface::theme public function Renders row values using $this->themeFunctions() as #theme. 1
FieldHandlerInterface::tokenizeValue public function Replaces a value with tokens from the last field. 1
FieldHandlerInterface::useStringGroupBy public function Determines if this field can be grouped in the results. 1
PluginInspectionInterface::getPluginDefinition public function Gets the definition of the plugin implementation. 6
PluginInspectionInterface::getPluginId public function Gets the plugin ID of the plugin instance. 2
ViewsHandlerInterface::access public function Check whether given user has access to this handler. 1
ViewsHandlerInterface::adminLabel public function Return a string representing this handler's name in the UI. 1
ViewsHandlerInterface::adminSummary public function Provide text for the administrative summary. 1
ViewsHandlerInterface::breakString public static function Breaks x,y,z and x+y+z into an array. 1
ViewsHandlerInterface::broken public function Determines if the handler is considered 'broken'. 1
ViewsHandlerInterface::ensureMyTable public function Ensures that the main table for this handler is in the query. 1
ViewsHandlerInterface::getEntityType public function Determines the entity type used by this handler. 1
ViewsHandlerInterface::getField public function Shortcut to get a handler's raw field value. 1
ViewsHandlerInterface::getJoin public function Get the join object that should be used for this handler. 1
ViewsHandlerInterface::getTableJoin public static function Fetches a handler to join one table to a primary table from the data cache. 1
ViewsHandlerInterface::postExecute public function Run after the view is executed, before the result is cached. 1
ViewsHandlerInterface::preQuery public function Run before the view is built. 1
ViewsHandlerInterface::sanitizeValue public function Sanitize the value for output. 1
ViewsHandlerInterface::setRelationship public function Sets up any needed relationship. 1
ViewsHandlerInterface::showExposeForm public function Shortcut to display the exposed options form. 1
ViewsPluginInterface::buildOptionsForm public function Provide a form to edit options for this plugin. 1
ViewsPluginInterface::destroy public function Clears a plugin. 1
ViewsPluginInterface::filterByDefinedOptions public function Filter out stored options depending on the defined options. 1
ViewsPluginInterface::getAvailableGlobalTokens public function Returns an array of available token replacements. 1
ViewsPluginInterface::getProvider public function Returns the plugin provider. 1
ViewsPluginInterface::globalTokenForm public function Adds elements for available core tokens to a form. 1
ViewsPluginInterface::globalTokenReplace public function Returns a string with any core tokens replaced. 1
ViewsPluginInterface::init public function Initialize the plugin. 1
ViewsPluginInterface::pluginTitle public function Return the human readable name of the display. 1
ViewsPluginInterface::preRenderAddFieldsetMarkup public static function Moves form elements into fieldsets for presentation purposes. 1
ViewsPluginInterface::preRenderFlattenData public static function Flattens the structure of form elements. 1
ViewsPluginInterface::query public function Add anything to the query that we might need to. 1
ViewsPluginInterface::submitOptionsForm public function Handle any special handling on the validate form. 1
ViewsPluginInterface::summaryTitle public function Returns the summary of the settings in the display. 1
ViewsPluginInterface::themeFunctions public function Provide a full list of possible theme templates used by this style. 1
ViewsPluginInterface::unpackOptions public function Unpacks options over our existing defaults. 1
ViewsPluginInterface::usesOptions public function Returns the usesOptions property. 1
ViewsPluginInterface::validate public function Validate that the plugin is correct and can be saved. 1
ViewsPluginInterface::validateOptionsForm public function Validate the options form. 1

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.