-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Relayout of Training/Workshops and Service Catalog (#23)
- Loading branch information
1 parent
760471b
commit 717fadd
Showing
24 changed files
with
1,497 additions
and
397 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
<?php | ||
/******************* | ||
** Enable Person ** | ||
*******************/ | ||
\Drupal\node\Entity\Node::load(13)->setPublished()->save(); | ||
|
||
/**************** | ||
** Menu Items ** | ||
****************/ | ||
// External Link | ||
\Drupal\menu_link_content\Entity\MenuLinkContent::create(["title" => "Submenu link", "link" => ["uri" => "https://google.com"], "menu_name" => "main", "parent" => "menu_link_field:node_field_menulink_e18a741f-7d86-492a-a02f-7ca73989ca13_und", "expanded" => TRUE, "weight" => 0])->save(); | ||
|
||
|
||
/******************** | ||
** Airtable Items ** | ||
********************/ | ||
$at_menu = \Drupal\menu_link_content\Entity\MenuLinkContent::create(["title" => "Airtable", "link" => ["uri" => "internal:/"], "menu_name" => "main", "parent" => "", "expanded" => TRUE, "weight" => 0]); | ||
$at_menu->save(); | ||
$at_menu_id = "menu_link_content:" . $at_menu->uuid(); | ||
$airtable_pages = [ | ||
[ | ||
'title' => 'Service Catalog', | ||
'wysiwyg_text' => '{"type":"airtable","view": "service_catalog"}', | ||
'menu_parent' => $at_menu_id, | ||
], | ||
[ | ||
'title' => 'Past Trainings & Workshops', | ||
'wysiwyg_text' => '{"type":"airtable","view": "training_past"}', | ||
'menu_parent' => $at_menu_id, | ||
], | ||
[ | ||
'title' => 'Upcoming Trainings & Workshops', | ||
'wysiwyg_text' => '{"type":"airtable","view": "training_upcoming"}', | ||
'menu_parent' => $at_menu_id, | ||
], | ||
[ | ||
'title' => 'All Training', | ||
'wysiwyg_text' => '{"type":"airtable","view": "training"}', | ||
'menu_parent' => '', | ||
], | ||
]; | ||
|
||
|
||
foreach ($airtable_pages as $page) { | ||
// Create Service Catalog Node | ||
$at_node = \Drupal::entityTypeManager()->getStorage("node")->create([ | ||
"type" => "stanford_page", | ||
"title" => $page['title'], | ||
]); | ||
$at_node->save(); | ||
|
||
// Create layout for paragraph for Service Catalog. | ||
$at_paragraph_layout = \Drupal::entityTypeManager()->getStorage("paragraph")->create([ | ||
"type" => "stanford_layout", | ||
"parent_id" => $at_node->id(), | ||
"parent_type" => "node", | ||
"parent_field_name" => "su_page_components", | ||
]); | ||
|
||
$at_paragraph_layout->setBehaviorSettings("layout_paragraphs", [ | ||
"layout" => "layout_paragraphs_1_column", | ||
"config" => [ | ||
"label" => "" | ||
], | ||
"parent_uuid" => "", | ||
"region" => "" | ||
]); | ||
$at_paragraph_layout->save(); | ||
|
||
// Create paragraph for Service Catalog | ||
$at_paragraph = \Drupal::entityTypeManager()->getStorage("paragraph")->create([ | ||
"type" => "stanford_wysiwyg", | ||
"parent_id" => $at_node->id(), | ||
"parent_type" => "node", | ||
"parent_field_name" => "su_page_components", | ||
"su_wysiwyg_text" => $page['wysiwyg_text'], | ||
]); | ||
|
||
$at_paragraph->setBehaviorSettings("layout_paragraphs", [ | ||
"parent_uuid" => $at_paragraph_layout->uuid(), | ||
"region" => "main" | ||
]); | ||
$at_paragraph->save(); | ||
|
||
// Add paragraph to service catalog node. | ||
$at_node->su_page_components = [ | ||
[ | ||
"target_id" => $at_paragraph_layout->id(), | ||
"target_revision_id" => $at_paragraph_layout->getRevisionId() | ||
], | ||
[ | ||
"target_id" => $at_paragraph->id(), | ||
"target_revision_id" => $at_paragraph->getRevisionId() | ||
] | ||
]; | ||
$at_node->save(); | ||
|
||
// Set Menu | ||
\Drupal\menu_link_content\Entity\MenuLinkContent::create(["title" => $page['title'], "link" => ["uri" => "internal:/node/" . $at_node->id()], "menu_name" => "main", "parent" => $page['menu_parent'], "expanded" => TRUE, "weight" => 0])->save(); | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.