function Block::preSave

Same name in other branches
  1. 8.9.x core/modules/block/src/Entity/Block.php \Drupal\block\Entity\Block::preSave()
  2. 10 core/modules/block/src/Entity/Block.php \Drupal\block\Entity\Block::preSave()
  3. 11.x core/modules/block/src/Entity/Block.php \Drupal\block\Entity\Block::preSave()

Overrides ConfigEntityBase::preSave

File

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

Class

Block
Defines a Block configuration entity class.

Namespace

Drupal\block\Entity

Code

public function preSave(EntityStorageInterface $storage) {
    parent::preSave($storage);
    // 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();
    }
}

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