class ExpressionContainerFormBase

Form handler for action containers.

Hierarchy

Expanded class hierarchy of ExpressionContainerFormBase

File

src/Form/Expression/ExpressionContainerFormBase.php, line 11

Namespace

Drupal\rules\Form\Expression
View 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

Title Sort descending Modifiers Object type Summary Overrides
ExpressionContainerFormBase::getParameterDescription protected function Helper function to extract context parameter names/values from the config.
ExpressionFormInterface::form public function Adds elements specific to the expression to the form. 5
ExpressionFormTrait::submitForm public function Implements ExpressionFormInterface::submitForm(). 3
ExpressionFormTrait::validateForm public function Implements ExpressionFormInterface::validateForm().
RulesUiHandlerTrait::$rulesUiHandler protected property The rules UI handler.
RulesUiHandlerTrait::getRulesUiHandler public function Gets the rules UI handler of the current route.
RulesUiHandlerTrait::setRulesUiHandler public function Sets the Rules UI handler.
StringTranslationTrait::$stringTranslation protected property The string translation service. 3
StringTranslationTrait::formatPlural protected function Formats a string containing a count of items.
StringTranslationTrait::getNumberOfPlurals protected function Returns the number of plurals supported by a given language.
StringTranslationTrait::getStringTranslation protected function Gets the string translation service.
StringTranslationTrait::setStringTranslation public function Sets the string translation service to use. 2
StringTranslationTrait::t protected function Translates a string to the current language or to a given language.