function _system_update_create_block

_system_update_create_block($name, $theme_name, array $values)

Helper function to create block configuration objects for an update.

Parameters

string $name: The name of the config object.

string $theme_name: The name of the theme the block is associated with.

array $values: The block config values.

File

core/modules/system/system.install, line 1361
Install, update and uninstall functions for the system module.

Code

function _system_update_create_block($name, $theme_name, array $values) {
  if (!\Drupal::service('config.storage')->exists($name)) {
    $block = \Drupal::configFactory()->getEditable($name);
    $values['uuid'] = \Drupal::service('uuid')->generate();
    $values['theme'] = $theme_name;
    $values['dependencies.theme'] = [$theme_name];
    foreach ($values as $key => $value) {
      $block->set($key, $value);
    }
    $block->save();
  }
}

© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/core!modules!system!system.install/function/_system_update_create_block/8.1.x