protected function CustomBlockFormController::prepareEntity

Overrides \Drupal\Core\Entity\EntityFormController::prepareEntity().

Prepares the custom block object.

Fills in a few default values, and then invokes hook_custom_block_prepare() on all modules.

Overrides EntityFormController::prepareEntity

File

drupal/core/modules/block/custom_block/lib/Drupal/custom_block/CustomBlockFormController.php, line 27
Contains \Drupal\custom_block\CustomBlockFormController.

Class

CustomBlockFormController
Form controller for the custom block edit forms.

Namespace

Drupal\custom_block

Code

protected function prepareEntity() {
  $block = $this->entity;

  // Set up default values, if required.
  $block_type = entity_load('custom_block_type', $block->type->value);

  // If this is a new custom block, fill in the default values.
  if (isset($block->id->value)) {
    $block
      ->set('log', NULL);
  }

  // Always use the default revision setting.
  $block
    ->setNewRevision($block_type->revision);
  module_invoke_all('custom_block_prepare', $block);
}