Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. Block.php

function Block::preSave

Overrides ConfigEntityBase::preSave

File

core/modules/block/src/Entity/Block.php, line 353

Class

Block
Defines a Block configuration entity class.

Namespace

Drupal\block\Entity

Code

public function preSave(EntityStorageInterface $storage) {
    parent::preSave($storage);
    if (!is_int($this->weight)) {
        @trigger_error('Saving a block with a non-integer weight is deprecated in drupal:11.1.0 and removed in drupal:12.0.0. See https://www.drupal.org/node/3462474', E_USER_DEPRECATED);
        $this->setWeight((int) $this->weight);
    }
    // Ensure the region is valid to mirror the behavior of block_rebuild().
    // This is done primarily for backwards compatibility support of
    // \Drupal\block\BlockInterface::BLOCK_REGION_NONE.
    $regions = system_region_list($this->theme);
    if (!isset($regions[$this->region]) && $this->status()) {
        $this->setRegion(system_default_region($this->theme))
            ->disable();
    }
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal