function ViewsHooks::blockPresave

Implements hook_ENTITY_TYPE_presave() for blocks.

Attributes

#[Hook('block_presave')]

File

core/modules/views/src/Hook/ViewsHooks.php, line 385

Class

ViewsHooks
Hook implementations for views.

Namespace

Drupal\views\Hook

Code

public function blockPresave(BlockInterface $block) : void {
  if (str_starts_with($block->getPluginId(), 'views_block:')) {
    $settings = $block->get('settings');
    if (isset($settings['items_per_page']) && $settings['items_per_page'] === 'none') {
      @trigger_error('Saving a views block with "none" items per page is deprecated in drupal:11.2.0 and removed in drupal:12.0.0. To use the items per page defined by the view, use NULL. See https://www.drupal.org/node/3522240', E_USER_DEPRECATED);
      $settings['items_per_page'] = NULL;
      $block->set('settings', $settings);
    }
  }
}

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