You are here

function bootstrap_kit_demo_install in Bootstrap Kit 8.3

Same name and namespace in other branches
  1. 8.4 bootstrap_kit_demo/bootstrap_kit_demo.install \bootstrap_kit_demo_install()

Implements hook_install().

File

bootstrap_kit_demo/bootstrap_kit_demo.install, line 6

Code

function bootstrap_kit_demo_install() {
  $image_id = array_values(\Drupal::entityQuery('brick')
    ->condition('type', 'image')
    ->execute())[0];
  $text_id = array_values(\Drupal::entityQuery('brick')
    ->condition('type', 'text')
    ->execute())[0];
  $entity_manager = \Drupal::entityManager();
  $columns = $entity_manager
    ->getStorage('brick')
    ->create([
    'type' => 'layout',
    'title' => 'Columns',
  ]);
  $columns
    ->save();
  $accordion = $entity_manager
    ->getStorage('brick')
    ->create([
    'type' => 'layout',
    'title' => 'Accordion',
  ]);
  $accordion
    ->save();
  $carousel = $entity_manager
    ->getStorage('brick')
    ->create([
    'type' => 'layout',
    'title' => 'Carousel',
  ]);
  $carousel
    ->save();
  $tabs = $entity_manager
    ->getStorage('brick')
    ->create([
    'type' => 'layout',
    'title' => 'Tabs',
  ]);
  $tabs
    ->save();
  $jumbo = $entity_manager
    ->getStorage('brick')
    ->create([
    'type' => 'wrapper',
    'title' => 'Jumbotron',
  ]);
  $jumbo
    ->save();
  $page = $entity_manager
    ->getStorage('node')
    ->create([
    'type' => 'bricky',
    'title' => 'Example page powered by Bricks and Bootstrap Kit',
    'field_body' => [
      [
        'depth' => 0,
        'target_id' => $tabs
          ->id(),
        'options' => [
          'layout' => 'bs_tabs',
        ],
      ],
      [
        'depth' => 1,
        'target_id' => $columns
          ->id(),
        'options' => [
          'layout' => 'bs_columns',
        ],
      ],
      [
        'depth' => 2,
        'target_id' => $image_id,
      ],
      [
        'depth' => 2,
        'target_id' => $text_id,
      ],
      [
        'depth' => 1,
        'target_id' => $accordion
          ->id(),
        'options' => [
          'layout' => 'bs_accordion',
        ],
      ],
      [
        'depth' => 2,
        'target_id' => $text_id,
      ],
      [
        'depth' => 2,
        'target_id' => $text_id,
      ],
      [
        'depth' => 2,
        'target_id' => $image_id,
      ],
      [
        'depth' => 1,
        'target_id' => $carousel
          ->id(),
        'options' => [
          'layout' => 'bs_carousel',
        ],
      ],
      [
        'depth' => 2,
        'target_id' => $image_id,
      ],
      [
        'depth' => 2,
        'target_id' => $image_id,
      ],
      [
        'depth' => 1,
        'target_id' => $tabs
          ->id(),
        'options' => [
          'layout' => 'bs_tabs',
        ],
      ],
      [
        'depth' => 2,
        'target_id' => $image_id,
      ],
      [
        'depth' => 2,
        'target_id' => $text_id,
      ],
      [
        'depth' => 1,
        'target_id' => $text_id,
      ],
      [
        'depth' => 1,
        'target_id' => $image_id,
      ],
      [
        'depth' => 1,
        'target_id' => $jumbo
          ->id(),
        'options' => [
          'css_class' => 'jumbotron',
        ],
      ],
      [
        'depth' => 2,
        'target_id' => $text_id,
      ],
    ],
  ]);
  $page
    ->save();
}