abstract class FieldFormatterConditionBase in Field Formatter Condition 8
Base class for Field formatter condition plugins.
Hierarchy
- class \Drupal\Component\Plugin\PluginBase implements DerivativeInspectionInterface, PluginInspectionInterface
- class \Drupal\fico\Plugin\FieldFormatterConditionBase implements FieldFormatterConditionInterface
Expanded class hierarchy of FieldFormatterConditionBase
10 files declare their use of FieldFormatterConditionBase
- HideDateTime.php in src/
Plugin/ Field/ FieldFormatter/ Condition/ HideDateTime.php - HideIfAuthor.php in src/
Plugin/ Field/ FieldFormatter/ Condition/ HideIfAuthor.php - HideIfBoolCheck.php in src/
Plugin/ Field/ FieldFormatter/ Condition/ HideIfBoolCheck.php - HideIfEmpty.php in src/
Plugin/ Field/ FieldFormatter/ Condition/ HideIfEmpty.php - HideIfString.php in src/
Plugin/ Field/ FieldFormatter/ Condition/ HideIfString.php
File
- src/
Plugin/ FieldFormatterConditionBase.php, line 11
Namespace
Drupal\fico\PluginView source
abstract class FieldFormatterConditionBase extends PluginBase implements FieldFormatterConditionInterface {
/**
* {@inheritdoc}
*/
public function getDefinition($plugin_id, $exception_on_invalid = TRUE) {
}
/**
* {@inheritdoc}
*/
public function getDefinitions() {
}
/**
* {@inheritdoc}
*/
public function hasDefinition($plugin_id) {
}
/**
* {@inheritdoc}
*/
public function createInstance($plugin_id, array $configuration = []) {
}
/**
* {@inheritdoc}
*/
public function getInstance(array $options) {
}
/**
* Alter the condition form.
*
* @param array $form
* Condition formular.
* @param array $settings
* Settings array.
*/
public abstract function alterForm(&$form, $settings);
/**
* Access control function.
*
* @param array $build
* The current build array.
* @param string $field
* The current field name.
* @param array $settings
* The current settings array.
*/
public abstract function access(&$build, $field, $settings);
/**
* Return the summary string.
*
* @param array $settings
* The current settings array.
*/
public abstract function summary($settings);
/**
* Check for entity_type in build.
*
* @param array $build
* The current build array.
*/
protected function getEntityType(array $build) {
if (isset($build['#entity_type'])) {
return $build['#entity_type'];
}
$types = \Drupal::entityManager()
->getDefinitions();
foreach ($types as $id => $type) {
if (!is_a($type, 'Drupal\\Core\\Entity\\ContentEntityType')) {
continue;
}
if (isset($build['#' . $id])) {
return $id;
}
}
return NULL;
}
/**
* Check for entity in build.
*
* @param array $build
* The current build array.
*/
protected function getEntity(array $build) {
if (!($type = $this
->getEntityType($build))) {
return FALSE;
}
return is_object($build['#' . $this
->getEntityType($build)]) ? $build['#' . $this
->getEntityType($build)] : NULL;
}
/**
* Load fields from a entity.
*
* @param string $entity_type
* Type of entity.
* @param string $bundle
* Entity bundle.
*
* @return array
* Returns the field definitions.
*/
protected function getEntityFields($entity_type, $bundle) {
$fields = [];
$entityManager = \Drupal::service('entity.manager');
if (!empty($entity_type) && !empty($bundle)) {
$fields = array_filter($entityManager
->getFieldDefinitions($entity_type, $bundle), function ($field_definition) {
return $field_definition instanceof FieldConfigInterface;
});
}
return $fields;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
FieldFormatterConditionBase:: |
abstract public | function | Access control function. | 10 |
FieldFormatterConditionBase:: |
abstract public | function | Alter the condition form. | 10 |
FieldFormatterConditionBase:: |
public | function |
Creates a pre-configured instance of a plugin. Overrides FactoryInterface:: |
|
FieldFormatterConditionBase:: |
public | function |
Gets a specific plugin definition. Overrides DiscoveryInterface:: |
|
FieldFormatterConditionBase:: |
public | function |
Gets the definition of all plugins for this type. Overrides DiscoveryInterface:: |
|
FieldFormatterConditionBase:: |
protected | function | Check for entity in build. | |
FieldFormatterConditionBase:: |
protected | function | Load fields from a entity. | |
FieldFormatterConditionBase:: |
protected | function | Check for entity_type in build. | |
FieldFormatterConditionBase:: |
public | function |
Gets a preconfigured instance of a plugin. Overrides MapperInterface:: |
|
FieldFormatterConditionBase:: |
public | function |
Indicates if a specific plugin definition exists. Overrides DiscoveryInterface:: |
|
FieldFormatterConditionBase:: |
abstract public | function | Return the summary string. | 10 |
PluginBase:: |
protected | property | Configuration information passed into the plugin. | 1 |
PluginBase:: |
protected | property | The plugin implementation definition. | 1 |
PluginBase:: |
protected | property | The plugin_id. | |
PluginBase:: |
constant | A string which is used to separate base plugin IDs from the derivative ID. | ||
PluginBase:: |
public | function |
Gets the base_plugin_id of the plugin instance. Overrides DerivativeInspectionInterface:: |
|
PluginBase:: |
public | function |
Gets the derivative_id of the plugin instance. Overrides DerivativeInspectionInterface:: |
|
PluginBase:: |
public | function |
Gets the definition of the plugin implementation. Overrides PluginInspectionInterface:: |
3 |
PluginBase:: |
public | function |
Gets the plugin_id of the plugin instance. Overrides PluginInspectionInterface:: |
|
PluginBase:: |
public | function | Determines if the plugin is configurable. | |
PluginBase:: |
public | function | Constructs a \Drupal\Component\Plugin\PluginBase object. | 92 |