function ViewsConfigUpdater::processTimestampFormatterTimeDiffUpdateHandler

Processes timestamp fields settings by adding time diff and tooltip.

Parameters

array $handler: A display handler.

string $handler_type: The handler type.

Return value

bool Whether the handler was updated.

2 calls to ViewsConfigUpdater::processTimestampFormatterTimeDiffUpdateHandler()
ViewsConfigUpdater::needsTimestampFormatterTimeDiffUpdate in core/modules/views/src/ViewsConfigUpdater.php
Updates the timestamp fields settings by adding time diff and tooltip.
ViewsConfigUpdater::updateAll in core/modules/views/src/ViewsConfigUpdater.php
Performs all required updates.

File

core/modules/views/src/ViewsConfigUpdater.php, line 363

Class

ViewsConfigUpdater
Provides a BC layer for modules providing old configurations.

Namespace

Drupal\views

Code

protected function processTimestampFormatterTimeDiffUpdateHandler(array &$handler, string $handler_type) : bool {
    if ($handler_type === 'field' && isset($handler['type'])) {
        $plugin_definition = $this->formatterPluginManager
            ->getDefinition($handler['type'], FALSE);
        // Check also potential plugins extending TimestampFormatter.
        if (!$plugin_definition || !is_a($plugin_definition['class'], TimestampFormatter::class, TRUE)) {
            return FALSE;
        }
        if (!isset($handler['settings']['tooltip']) || !isset($handler['settings']['time_diff'])) {
            $handler['settings'] += $plugin_definition['class']::defaultSettings();
            // Existing timestamp formatters don't have tooltip.
            $handler['settings']['tooltip'] = [
                'date_format' => '',
                'custom_date_format' => '',
            ];
            return TRUE;
        }
    }
    return FALSE;
}

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