abstract class ExpressionContainerFormBase in Rules 8.3
Form handler for action containers.
Hierarchy
- class \Drupal\rules\Form\Expression\ExpressionContainerFormBase implements ExpressionFormInterface uses StringTranslationTrait, ExpressionFormTrait, RulesUiHandlerTrait
Expanded class hierarchy of ExpressionContainerFormBase
File
- src/
Form/ Expression/ ExpressionContainerFormBase.php, line 11
Namespace
Drupal\rules\Form\ExpressionView source
abstract class ExpressionContainerFormBase implements ExpressionFormInterface {
use StringTranslationTrait;
use ExpressionFormTrait;
use RulesUiHandlerTrait;
/**
* Helper function to extract context parameter names/values from the config.
*
* @param array $configuration
* Configuration entity as a configuration array.
*
* @return string
* String containing a summary of context parameter names and values.
*/
protected function getParameterDescription(array $configuration) {
$parameters = [];
// 'context_mapping' is for context parameters set in data selector mode.
// 'context_values' is for context parameters set in direct input mode.
$context = [];
if (isset($configuration['context_values']) && isset($configuration['context_mapping'])) {
// @todo Remove this if() check on context_values and context_mapping when
// https://www.drupal.org/project/rules/issues/3103808 is fixed.
$context = $configuration['context_mapping'] + $configuration['context_values'];
}
foreach ($context as $key => $value) {
if ($value === FALSE) {
$value = 'FALSE';
}
elseif ($value === TRUE) {
$value = 'TRUE';
}
elseif ($value === NULL) {
$value = 'NULL';
}
elseif ($value === '') {
$value = "''";
}
elseif (is_array($value)) {
$value = '[' . implode(', ', $value) . ']';
}
// @todo Truncate $value if it's "too long", so as not to clutter UI.
// Perhaps we can display the full value on hover.
$parameters[] = $key . ': ' . $value;
}
// Build description string.
if (empty($parameters)) {
$description = $this
->t('Parameters: <none>');
}
else {
$description = $this
->t('Parameters: @name-value', [
'@name-value' => implode(', ', $parameters),
]);
}
return $description;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
ExpressionContainerFormBase:: |
protected | function | Helper function to extract context parameter names/values from the config. | |
ExpressionFormInterface:: |
public | function | Adds elements specific to the expression to the form. | 5 |
ExpressionFormTrait:: |
public | function | Implements ExpressionFormInterface::submitForm(). | 3 |
ExpressionFormTrait:: |
public | function | Implements ExpressionFormInterface::validateForm(). | |
RulesUiHandlerTrait:: |
protected | property | The rules UI handler. | |
RulesUiHandlerTrait:: |
public | function | Gets the rules UI handler of the current route. | |
RulesUiHandlerTrait:: |
public | function | Sets the Rules UI handler. | |
StringTranslationTrait:: |
protected | property | The string translation service. | 1 |
StringTranslationTrait:: |
protected | function | Formats a string containing a count of items. | |
StringTranslationTrait:: |
protected | function | Returns the number of plurals supported by a given language. | |
StringTranslationTrait:: |
protected | function | Gets the string translation service. | |
StringTranslationTrait:: |
public | function | Sets the string translation service to use. | 2 |
StringTranslationTrait:: |
protected | function | Translates a string to the current language or to a given language. |