View source
<?php
use Drupal\node\Entity\Node;
function brainstorm_main_slider_install() {
$title = 'Responsive theme';
$node = Node::create(array(
'type' => 'main_slider',
'title' => $title,
'uid' => '1',
'status' => 1,
'path' => '/' . _brainstorm_profile_clean_alias($title),
));
$output = file_get_contents(drupal_get_path('profile', 'brainstorm_profile') . '/images/slide-1.jpg');
$file = file_save_data($output, 'public://brainstorm-placeholder/slide-1.jpg', FILE_EXISTS_REPLACE);
$node->field_background_image
->setValue($file
->id());
$output = file_get_contents(drupal_get_path('profile', 'brainstorm_profile') . '/images/slider-1.png');
$file = file_save_data($output, 'public://brainstorm-placeholder/slider-1.png', FILE_EXISTS_REPLACE);
$files[] = $file
->id();
$output = file_get_contents(drupal_get_path('profile', 'brainstorm_profile') . '/images/slider-1-tablet.png');
$file = file_save_data($output, 'public://brainstorm-placeholder/slider-1-tablet.png', FILE_EXISTS_REPLACE);
$files[] = $file
->id();
$node->field_main_slider_image
->setValue($files);
$node->body->value = '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!';
$node
->save();
$title = 'Retina ready';
$node = Node::create(array(
'type' => 'main_slider',
'title' => $title,
'uid' => '1',
'status' => 1,
'path' => '/' . _brainstorm_profile_clean_alias($title),
));
$output = file_get_contents(drupal_get_path('profile', 'brainstorm_profile') . '/images/slide-2.jpg');
$file = file_save_data($output, 'public://brainstorm-placeholder/slide-2.jpg', FILE_EXISTS_REPLACE);
$node->field_background_image
->setValue($file
->id());
$output = file_get_contents(drupal_get_path('profile', 'brainstorm_profile') . '/images/slider-2.png');
$file = file_save_data($output, 'public://brainstorm-placeholder/slider-2.png', FILE_EXISTS_REPLACE);
$node->field_main_slider_image
->setValue($file
->id());
$node->body->value = '<div class="title-ul">Owerfully responsive</div><ul><li>Lorem ipsum' . ' dolor sit amet</li><li>Dolor sit amet</li><li>Sit amet psum dollor</li>' . '<ul>';
$node->body->format = 'full_html';
$node
->save();
$title = 'Discover our corporate theme';
$node = Node::create(array(
'type' => 'main_slider',
'title' => $title,
'uid' => '1',
'status' => 1,
'path' => '/' . _brainstorm_profile_clean_alias($title),
));
$output = file_get_contents(drupal_get_path('profile', 'brainstorm_profile') . '/images/slide-3.jpg');
$file = file_save_data($output, 'public://brainstorm-placeholder/slide-3.jpg', FILE_EXISTS_REPLACE);
$node->field_background_image
->setValue($file
->id());
$node->body->value = '<div class="title-item-2"><p>Discover our corporate theme </p></div>' . '<div class="text-item-2"><p>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.<br/>At vero eos et accusamus et iusto odio dignissimos' . ' ducimus qui blanditiis praesentium voluptatum deleniti atque corrupti' . ' quos dolores et quas molestias excepturi sint occaecati cupiditate.</p>' . '</div>';
$node->body->format = 'full_html';
$node
->save();
}