Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $findings = [
- [
- 'location' => '204',
- 'finding_type' => 132,
- 'comments' => 'Needs cord cover',
- ],
- [
- 'location' => '104',
- 'finding_type' => 132,
- 'comments' => 'Needs cord cover',
- ],
- [
- 'location' => '103',
- 'finding_type' => 132,
- 'comments' => 'Needs cord cover',
- ],
- [
- 'location' => '302',
- 'finding_type' => 132,
- 'comments' => 'Needs cord cover',
- ],
- [
- 'location' => '202',
- 'finding_type' => 132,
- 'comments' => 'Needs cord cover',
- ],
- [
- 'location' => '304',
- 'finding_type' => 132,
- 'comments' => 'Needs cord cover',
- ],
- [
- 'location' => 'Portable 3',
- 'finding_type' => 132,
- 'comments' => 'Needs cord cover',
- ],
- [
- 'location' => 'Portable 2',
- 'finding_type' => 132,
- 'comments' => 'Needs cord cover',
- ],
- [
- 'location' => '907',
- 'finding_type' => 132,
- 'comments' => 'Needs cord cover',
- ],
- ];
- $walkthrough = \Drupal\node\Entity\Node::create([
- 'type' => 'walkthrough',
- 'field_date' => '2018-11-13',
- 'field_facility' => ['target_id' => 17],
- 'field_roster' => "",
- 'status' => 0,
- ]);
- $walkthrough->save();
- foreach ($findings as $finding) {
- $type = \Drupal\taxonomy\Entity\Term::load($finding['finding_type']);
- $node = \Drupal\node\Entity\Node::create([
- 'type' => 'finding',
- 'field_walkthrough' => ['target_id' => $walkthrough->id()],
- 'field_location' => $finding['location'],
- 'field_finding_type' => ['target_id' => $type->id()],
- 'field_comments' => $finding['comments'],
- 'field_assigned_to' => $type->field_default_assignment->value ?: NULL,
- ]);
- $node->save();
- }
Add Comment
Please, Sign In to add comment