function ViewsConfigUpdater::addLabelIfMissing

Adds a label to views which don't have one.

Parameters

\Drupal\views\ViewEntityInterface $view: The view to update.

Return value

bool Whether the view was updated.

1 call to ViewsConfigUpdater::addLabelIfMissing()
ViewsConfigUpdater::updateAll in core/modules/views/src/ViewsConfigUpdater.php
Performs all required updates.

File

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

Class

ViewsConfigUpdater
Provides a BC layer for modules providing old configurations.

Namespace

Drupal\views

Code

public function addLabelIfMissing(ViewEntityInterface $view) : bool {
    if (!$view->get('label')) {
        $view->set('label', $view->id());
        return TRUE;
    }
    return FALSE;
}

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