forked from Obiz/drupal-fixtures
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathfixtures.node.inc
More file actions
32 lines (30 loc) · 832 Bytes
/
fixtures.node.inc
File metadata and controls
32 lines (30 loc) · 832 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
<?php
/**
* Create all nodes
*/
function fixtures_create_nodes() {
$fixtures = fixtures_get_fixtures('node');
foreach ($fixtures as $fixture) {
foreach ($fixture as $node_name => $node_array) {
$node = fixture_create_node($node_array);
}
}
return "debugging fixtures";
}
/**`
* Create single node from YAML array
*/
function fixture_create_node($node_array) {
$node = new stdClass();
$node->type = $node_array['type'];
//node_object_prepare($node);
$node->title = $node_array['title'];
$node->body['und'][0]['value'] = $node_array['body'];
$node->body['und'][0]['format'] = 'full_html';
$node->created = strtotime($node_array['date']);
$node->changed = $node->created;
$node->language = 'en';
$node->path = array('alias' => $node_array['path']);
node_save($node);
return $node;
}