You are here

bricks_default_eck.install in Bricks​ 8

File

modules/bricks_default_eck/bricks_default_eck.install
View source
<?php

/**
 * @file
 * {@inheritdoc}
 */

/**
 * Implements hook_install().
 */
function bricks_default_eck_install() {
  $entity_manager = \Drupal::entityManager();
  $layout = $entity_manager
    ->getStorage('basic')
    ->create([
    'type' => 'layout',
    'title' => 'Layout',
  ]);
  $layout
    ->save();
  $data = file_get_contents(drupal_get_path('theme', 'bartik') . '/screenshot.png');
  $file = file_save_data($data, 'public://bartik.png');
  $image = $entity_manager
    ->getStorage('basic')
    ->create([
    'type' => 'image',
    'title' => 'Image',
    'field_image' => [
      'target_id' => $file
        ->id(),
    ],
  ]);
  $image
    ->save();
  $text = $entity_manager
    ->getStorage('basic')
    ->create([
    'type' => 'text',
    'title' => 'Text',
    'field_text' => [
      'value' => 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.',
      'format' => 'plain_text',
    ],
  ]);
  $text
    ->save();
  $wrapper = $entity_manager
    ->getStorage('basic')
    ->create([
    'type' => 'wrapper',
    'title' => 'Wrapper',
  ]);
  $wrapper
    ->save();
  $page = $entity_manager
    ->getStorage('node')
    ->create([
    'type' => 'bricky_eck',
    'title' => 'Bricks + ECK = ♥',
    'field_body_eck' => [
      [
        'depth' => 0,
        'target_id' => $layout
          ->id(),
        'options' => [
          'layout' => 'layout_twocol',
        ],
      ],
      [
        'depth' => 1,
        'target_id' => $text
          ->id(),
      ],
      [
        'depth' => 1,
        'target_id' => $image
          ->id(),
      ],
      [
        'depth' => 1,
        'target_id' => $text
          ->id(),
        'options' => [
          'css_class' => 'text-align-right',
        ],
      ],
      [
        'depth' => 1,
        'target_id' => $text
          ->id(),
      ],
    ],
  ]);
  $page
    ->save();
}

Functions

Namesort descending Description
bricks_default_eck_install Implements hook_install().