You are here

public static function BlocksController::deleteBlocks in Structure Sync 8

Same name and namespace in other branches
  1. 2.x src/Controller/BlocksController.php \Drupal\structure_sync\Controller\BlocksController::deleteBlocks()

Function to delete all custom blocks.

1 call to BlocksController::deleteBlocks()
BlocksController::importBlocks in src/Controller/BlocksController.php
Function to import custom blocks.

File

src/Controller/BlocksController.php, line 384

Class

BlocksController
Controller for syncing custom blocks.

Namespace

Drupal\structure_sync\Controller

Code

public static function deleteBlocks(&$context) {
  $entities = StructureSyncHelper::getEntityManager()
    ->getStorage('block_content')
    ->loadMultiple();
  StructureSyncHelper::getEntityManager()
    ->getStorage('block_content')
    ->delete($entities);
  if (array_key_exists('drush', $context) && $context['drush'] === TRUE) {
    drush_log('Deleted all custom blocks', 'ok');
  }
  StructureSyncHelper::logMessage('Deleted all custom blocks');
}