diff --git a/uw_fdsu_theme_resp.theme b/uw_fdsu_theme_resp.theme index 5aaf36d3289e7bc0fca69db43c643f851b49d9ee..beccf2296ee09e5cce40a0f0dbd2a272d7104c25 100644 --- a/uw_fdsu_theme_resp.theme +++ b/uw_fdsu_theme_resp.theme @@ -53,41 +53,6 @@ function uw_fdsu_theme_resp_preprocess_responsive_image(&$variables) { $variables['sources'] = $new_sources; } -/** - * A recursive function to count the number of menu items. - * - * @param $menus - * The array list of menu items. - * @param $menu_items_count - * The reference to the number of items variable. - */ -function _uw_fdsu_theme_resp_count_menu_items($menus, &$menu_items_count) { - - // Step through each of the menus. - foreach ($menus as $menu) { - - // If there is a submenu, then recursively go down through the list, - // until we get to place that doesnt have a submenu and we will - // increment the menu items count. - if (isset($menu['submenu']) && count($menu['submenu'] > 0)) { - - // Step through each of the submenus and send back to this function. - foreach ($menu['submenus'] as $submenu) { - - // Keep calling this function until we have no submenus. - _uw_fdsu_theme_resp_count_menu_items($submenu, $menu_items_count); - } - } - - // Here we have no submenus, so increment the menu items counter. - else { - - // Increment the menu items counter. - $menu_items_count++; - } - } -} - /** * Implements hook_preprocess_region(). */ @@ -119,7 +84,7 @@ function uw_fdsu_theme_resp_preprocess_region(&$variables) { } /** - * Implements hook_FORM_ID_alter. + * Implements hook_FORM_ID_alter(). * * Add settings for colour scheme. */ @@ -179,7 +144,7 @@ function _uw_fdsu_theme_resp_get_field_value_from_paragraph($paragraph, $field) * * @param array $variables * The variables array. - * @param object $field + * @param \Drupal\image\Plugin\Field\FieldType\ImageItem $field * The field object. * @param string $responsive_image_style * The ID of the responsive image style. @@ -226,7 +191,7 @@ function _uw_fdsu_theme_resp_add_responsive_image_variables(array &$variables, I /** * Get image properties from an image field. * - * @param object $field + * @param \Drupal\file\Plugin\Field\FieldType\FileFieldItemList $field * The image field. * * @return array|null @@ -256,37 +221,51 @@ function _uw_fdsu_theme_resp_get_image_info(FileFieldItemList $field) { */ function uw_fdsu_theme_resp_preprocess_block(&$variables) { - // If we are in layout builder (this is set much earlier in the page load process), - // then continue to look if we need to add the admin_label and css classes. + // If we are in layout builder (this is set much earlier in + // the page load process), then continue to look if we need + // to add the admin_label and css classes. if (isset($variables['in_layout_builder']) && $variables['in_layout_builder'] == TRUE) { // Get the block manager object. $blockManager = \Drupal::service('plugin.manager.block'); - // Get the plugin definitions for the block, using the plugin_id of the block. + // Get the plugin definitions for the block, using the + // plugin_id of the block. $plugin_definitions = $blockManager->getDefinition($variables['plugin_id']); - // The admin labels to exclude, these are ones that we do not want the admin label - // to appear on the layout builder page. - $admin_labels_to_exclude = ['Messages', 'Tabs', 'Page title', 'Global header', 'Main navigation', "Site footer block"]; + // The admin labels to exclude, these are ones that we do not + // want the admin label to appear on the layout builder page. + $admin_labels_to_exclude = [ + 'Messages', + 'Tabs', + 'Page title', + 'Global header', + 'Main navigation', + 'Site footer block', + ]; - // Check if the admin_label is an object, we need to do this because some admin labels - // are translatable and are therefore translatable markup objects (usually through code way of - // building blocks. Others are not, if translations are not turned on for this block (usually through - // the GUI way of creating a block, where the translation option is not set). + // Check if the admin_label is an object, we need to do this + // because some admin labels are translatable and are therefore + // translatable markup objects (usually through code way of + // building blocks. Others are not, if translations are not turned + // on for this block (usually through the GUI way of creating a block, + // where the translation option is not set). if (is_object($plugin_definitions['admin_label'])) { - // The admin label is a translatable markup, so just render the object to set the admin label variable.. + // The admin label is a translatable markup, so just render + // the object to set the admin label variable.. $admin_label = $plugin_definitions['admin_label']->render(); } else { - // The admin label is not an object so just set the admin label variable. + // The admin label is not an object so just set the + // admin label variable. $admin_label = $plugin_definitions['admin_label']; } - // If the admin label is not in the ones to exclude add it to the template variables and - // set the class to be used to display the admin label. + // If the admin label is not in the ones to exclude add it + // to the template variables and set the class to be used + // to display the admin label. if (!in_array($admin_label, $admin_labels_to_exclude)) { $variables['admin_label'] = $admin_label; $variables['attributes']['class'][] = 'in-layout-builder';