brainstorm_testimonials.install in Brainstorm profile 8
File
module/features/brainstorm_testimonials/brainstorm_testimonials.install
View source
<?php
use Drupal\node\Entity\Node;
function brainstorm_testimonials_install() {
$testimonials_titles = array(
'Choo web agency',
'Anna Puha',
);
$body = "Sed ut perspiciatis, unde omnis iste natus error sit voluptatem " . "accusantium doloremque laudantium, totam rem aperiam eaque ipsa, " . "uae ab illo inventore veritatis et quasi architecto beatae vitae " . "dicta sunt, explicabo.";
$count = 0;
foreach ($testimonials_titles as $title) {
$count++;
$path = _brainstorm_profile_clean_alias($title);
$node = Node::create(array(
'type' => 'testimonials',
'title' => $title,
'uid' => '1',
'status' => 1,
'path' => '/' . $path,
));
$file_name = 'testimonials-' . $count . '.png';
$output = file_get_contents(drupal_get_path('profile', 'brainstorm_profile') . '/images/' . $file_name);
$file = file_save_data($output, 'public://brainstorm-placeholder/' . $file_name, FILE_EXISTS_REPLACE);
$node->field_photo
->setValue($file
->id());
$node->body->value = $body;
$node->field_profession
->generateSampleItems();
$node
->save();
}
}