Skip to content

Instantly share code, notes, and snippets.

View jenitehan's full-sized avatar

Jeni Tehan jenitehan

View GitHub Profile
$parameters = new MenuTreeParameters();
$parameters->setMaxDepth(2)->onlyEnabledLinks();
$menuTreeService = Drupal::menuTree();
$tree = $menuTreeService->load('main', $parameters);
if ($tree) {
$build = $menuTreeService->build($tree);
@waako
waako / get_paragraph_type_from_field.php
Last active April 27, 2016 15:28 — forked from jenitehan/get_paragraph.php
Get paragraph type of child field item
<?php
/**
* Implements hook_preprocess_HOOK for field--field-structured-content-section.html.twig
*/
function TEMPLATE_preprocess_field__field_structured_content_section(&$variables) {
$items = $variables['items'];
foreach ($items as &$item) {
$paragraph = $item['content']['#paragraph'];
$para_type = $paragraph->getType();