brainstorm_client.install in Brainstorm profile 8
File
module/features/brainstorm_client/brainstorm_client.installView source
<?php
/**
* @file
*/
use Drupal\node\Entity\Node;
/**
* Implements hook_install().
*/
function brainstorm_client_install() {
$count = 0;
for ($count = 1; $count < 8; $count++) {
$title = 'Client ' . $count;
$node = Node::create(array(
'type' => 'client',
'title' => $title,
'uid' => '1',
'status' => 1,
'path' => '/' . _brainstorm_profile_clean_alias($title),
));
@mkdir('public://brainstorm-placeholder/');
$file_name = 'client_' . $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_clients_logo
->setValue($file
->id());
$node
->save();
}
}
Functions
Name | Description |
---|---|
brainstorm_client_install | Implements hook_install(). |