diff --git a/gesso_helper/src/Commands/GessoHelperCommands.php b/gesso_helper/src/Commands/GessoHelperCommands.php index 8d33a082030de58b26b2bbe32d342f0911466bd6..cca147562e79bd4852aec8abd2d04edc4e293120 100644 --- a/gesso_helper/src/Commands/GessoHelperCommands.php +++ b/gesso_helper/src/Commands/GessoHelperCommands.php @@ -42,7 +42,7 @@ class GessoHelperCommands extends DrushCommands implements SiteAliasManagerAware * @command gesso * @throws \Exception */ - public function gesso($name, array $options = ['description' => null, 'machine-name' => null]) { + public function gesso($name, array $options = ['description' => NULL, 'machine-name' => NULL]) { // Get new theme options. if (!isset($name)) { $name = $options['name']; @@ -67,7 +67,7 @@ class GessoHelperCommands extends DrushCommands implements SiteAliasManagerAware // Get theme paths. $drupalRoot = Drush::bootstrapManager()->getRoot(); $gesso_path = Path::join($drupalRoot, drupal_get_path('theme', 'gesso')); - $theme_path = substr($gesso_path, 0, strrpos( $gesso_path, '/')); + $theme_path = substr($gesso_path, 0, strrpos($gesso_path, '/')); $new_path = Path::join($theme_path, $machine_name); // Copy the Gesso theme directory recursively to the new theme’s location. @@ -140,7 +140,7 @@ class GessoHelperCommands extends DrushCommands implements SiteAliasManagerAware $this->io()->note(dt('The gulp commands for !name are still gessoBuild and gessoWatch. If you want to change ' . 'those, you will need to modify the gulpfile and any build processes and/or CI tools.', [ '!name' => $name, - ])); + ])); } /** @@ -186,7 +186,7 @@ class GessoHelperCommands extends DrushCommands implements SiteAliasManagerAware * before finally deleting the directory itself. * * @param string $path - * Path to the top-level directory + * Path to the top-level directory. */ private function gesso_recursive_rm($path) { if (is_dir($path)) { @@ -196,7 +196,8 @@ class GessoHelperCommands extends DrushCommands implements SiteAliasManagerAware $subpath = Path::join($path, $item); if (is_dir($subpath)) { $this->gesso_recursive_rm($subpath); - } else { + } + else { drush_op('unlink', $subpath); } } @@ -204,4 +205,5 @@ class GessoHelperCommands extends DrushCommands implements SiteAliasManagerAware drush_op('rmdir', $path); } } + } diff --git a/gesso_helper/src/TwigExtension/GessoExtensionAdapter.php b/gesso_helper/src/TwigExtension/GessoExtensionAdapter.php index db65fd7315a569e20c9dda0bc615601ced796b24..2d1e88293e8b774b2221e9d3ee66df86d5561771 100644 --- a/gesso_helper/src/TwigExtension/GessoExtensionAdapter.php +++ b/gesso_helper/src/TwigExtension/GessoExtensionAdapter.php @@ -1,15 +1,22 @@ <?php namespace Drupal\gesso_helper\TwigExtension; + /** - * Load custom twig functions from Pattern Lab + * Load custom twig functions from Pattern Lab. */ class GessoExtensionAdapter extends \Twig_Extension { + /** + * + */ public function __construct() { GessoExtensionLoader::init(); } + /** + * + */ public function getFunctions() { return GessoExtensionLoader::get(); } diff --git a/gesso_helper/src/TwigExtension/GessoExtensionLoader.php b/gesso_helper/src/TwigExtension/GessoExtensionLoader.php index 9ae3ce7639c5e0343274d428955d99271ea4fbf0..854bd5e0c38dda1ed0f87f527d02552536753b80 100644 --- a/gesso_helper/src/TwigExtension/GessoExtensionLoader.php +++ b/gesso_helper/src/TwigExtension/GessoExtensionLoader.php @@ -3,23 +3,32 @@ namespace Drupal\gesso_helper\TwigExtension; /** - * Load custom twig functions from Pattern Lab + * Load custom twig functions from Pattern Lab. */ class GessoExtensionLoader { static $objects = []; - static public function init() { + /** + * + */ + public static function init() { if (!self::$objects) { static::loadAll(); } } - static public function get() { + /** + * + */ + public static function get() { return !empty(self::$objects) ? self::$objects : []; } - static protected function loadAll() { + /** + * + */ + protected static function loadAll() { $theme = \Drupal::config('system.theme')->get('default'); $themeLocation = drupal_get_path('theme', $theme); $themePath = DRUPAL_ROOT . '/' . $themeLocation . '/'; @@ -27,7 +36,10 @@ class GessoExtensionLoader { static::load($fullPath . 'add_attributes.function.drupal.php'); } - static protected function load($file) { + /** + * + */ + protected static function load($file) { include $file; self::$objects[] = $function; } diff --git a/includes/block.inc b/includes/block.inc index 3b7dc7165b3852de901c3e9513f54d02fb6955e2..147c30ca77dadd4ba76f754cf28bec39197d0cb5 100644 --- a/includes/block.inc +++ b/includes/block.inc @@ -5,7 +5,7 @@ * Provides the necessary hooks for the block theme suggestions. */ -use \Drupal\block_content\BlockContentInterface; +use Drupal\block_content\BlockContentInterface; /** * Implements hook_theme_suggestions_HOOK_alter(). diff --git a/includes/field.inc b/includes/field.inc index 61e32f490edeb41f2653769700ad84d8b3cc0517..fb7cbd5e86a8ff9522c04f26fb8db59f0135d18a 100644 --- a/includes/field.inc +++ b/includes/field.inc @@ -5,6 +5,9 @@ * Field template functions. */ +/** + * + */ function gesso_theme_suggestions_field_alter(&$suggestions, $variables) { - $suggestions[] = 'field__node__' . $variables['element']['#field_name'] . '__' . $variables['element']['#bundle'] . '__' . $variables['element']['#view_mode']; + $suggestions[] = 'field__node__' . $variables['element']['#field_name'] . '__' . $variables['element']['#bundle'] . '__' . $variables['element']['#view_mode']; } diff --git a/includes/form.inc b/includes/form.inc index 37b52e7269947517edacd4cfb5e4064f961d6d50..f2268b465c07b7ba456e94c47966e0c19193c829 100644 --- a/includes/form.inc +++ b/includes/form.inc @@ -27,4 +27,4 @@ function gesso_preprocess_fieldset(&$vars) { function gesso_theme_suggestions_form_alter(array &$suggestions, array $variables) { $form_id = $variables['element']['#form_id']; $suggestions[] = 'form__' . $form_id; -} \ No newline at end of file +} diff --git a/includes/navigation.inc b/includes/navigation.inc index 0993fc3ea756ee224c44d272436af54a7e256e0e..5690e11052ff2edbe4ecd4fff5d7cde606c12737 100644 --- a/includes/navigation.inc +++ b/includes/navigation.inc @@ -1,33 +1,43 @@ <?php +/** + * @file + */ + /** * Implements theme_preprocess_menu_local_tasks() * * @param $variables */ - function gesso_preprocess_menu_local_tasks(&$variables) { - foreach (['primary', 'secondary'] as $type) { - $tabs = []; - - // Sort the tabs by #weight. - uasort($variables[$type], ['Drupal\Component\Utility\SortArray', 'sortByWeightProperty']); - - foreach (array_keys($variables[$type]) as $key) { - // Add the tab to a new array. - $tabs[$key] = [ - 'active' => $variables[$type][$key]['#active'], - 'url' => $variables[$type][$key]['#link']['url']->toString(), - 'text' => \Drupal\Component\Utility\Html::escape($variables[$type][$key]['#link']['title']) - ]; - - // Check if the tab should be shown by rendering the original. - $link = \Drupal::service('renderer')->render($variables[$type][$key]); - if (!$link) { - unset($tabs[$key]); - } - } - - // Overwrite the original tabs data. - $variables[$type] = $tabs; - } - } + +use Drupal\Component\Utility\Html; + +/** + * + */ +function gesso_preprocess_menu_local_tasks(&$variables) { + foreach (['primary', 'secondary'] as $type) { + $tabs = []; + + // Sort the tabs by #weight. + uasort($variables[$type], ['Drupal\Component\Utility\SortArray', 'sortByWeightProperty']); + + foreach (array_keys($variables[$type]) as $key) { + // Add the tab to a new array. + $tabs[$key] = [ + 'active' => $variables[$type][$key]['#active'], + 'url' => $variables[$type][$key]['#link']['url']->toString(), + 'text' => Html::escape($variables[$type][$key]['#link']['title']), + ]; + + // Check if the tab should be shown by rendering the original. + $link = \Drupal::service('renderer')->render($variables[$type][$key]); + if (!$link) { + unset($tabs[$key]); + } + } + + // Overwrite the original tabs data. + $variables[$type] = $tabs; + } +} diff --git a/includes/taxonomy.inc b/includes/taxonomy.inc index a8ace9a596349b0948f706e67df9422a45ff49a9..cf4cc4409702405cd981875a2aad43daaa6d46e4 100644 --- a/includes/taxonomy.inc +++ b/includes/taxonomy.inc @@ -1,5 +1,9 @@ <?php +/** + * @file + */ + /** * Implements theme_suggestions_taxonomy_term_alter() * diff --git a/includes/views.inc b/includes/views.inc index 559bfd1a8730f6a2a29e977694ff1f6c934a4646..d05e094727cad652604202f732fd3616ac9c13d0 100644 --- a/includes/views.inc +++ b/includes/views.inc @@ -1,7 +1,11 @@ <?php /** - * Implements views_theme_suggestions_views_view(). + * @file + */ + +/** + * Implements hook_theme_suggestions_views_view(). */ function views_theme_suggestions_views_view(array $variables) { $suggestions = []; @@ -15,7 +19,7 @@ function views_theme_suggestions_views_view(array $variables) { } /** - * Implements views_theme_suggestions_views_view_unformatted(). + * Implements hook_theme_suggestions_views_view_unformatted(). */ function views_theme_suggestions_views_view_unformatted(array $variables) { $suggestions = []; @@ -36,8 +40,8 @@ function gesso_preprocess_views_view(&$variables) { } /** -* Implements hook_theme_suggestions_container_alter(). -*/ + * Implements hook_theme_suggestions_container_alter(). + */ function gesso_theme_suggestions_container_alter(array &$suggestions, array $variables) { // A list of view names in which to exclude the container markup. // Included views will use container--no-wrapper.html.twig instead of container.html.twig. diff --git a/uw_fdsu_theme_resp.theme b/uw_fdsu_theme_resp.theme index 186950a10649c0d845c678cfdbbd6629940e6584..9728d8d827fc46bde4001ef6e07f7e87ce63d08a 100644 --- a/uw_fdsu_theme_resp.theme +++ b/uw_fdsu_theme_resp.theme @@ -5,9 +5,9 @@ * Theme file for uw_fdsu_theme_resp. */ -use Drupal\taxonomy\Entity\Term; -use Drupal\Core\Datetime; -use Drupal\Core\DateTimeZone; +use Drupal\file\Plugin\Field\FieldType\FileFieldItemList; +use Drupal\image\Plugin\Field\FieldType\ImageItem; +use Drupal\Core\Form\FormStateInterface; /** * @file @@ -42,11 +42,11 @@ function uw_fdsu_theme_resp_preprocess_responsive_image(&$variables) { foreach ($variables['sources'] as $source) { // Set the a variable with the actual source info that we need. - $new_sources[] = array( + $new_sources[] = [ 'srcset' => $source['srcset']->value(), 'media' => $source['media']->value(), 'type' => $source['type']->value(), - ); + ]; } // Set the sources variable to the new sources. @@ -82,7 +82,7 @@ function uw_fdsu_theme_resp_preprocess_region(&$variables) { * * Add settings for colour scheme. */ -function uw_fdsu_theme_resp_form_system_theme_settings_alter(&$form, \Drupal\Core\Form\FormStateInterface &$form_state, $form_id = NULL) { +function uw_fdsu_theme_resp_form_system_theme_settings_alter(&$form, FormStateInterface &$form_state, $form_id = NULL) { // Work-around for a core bug affecting admin themes. See issue #943212. if (isset($form_id)) { @@ -90,14 +90,14 @@ function uw_fdsu_theme_resp_form_system_theme_settings_alter(&$form, \Drupal\Cor } // Fieldset for colour scheme. - $form['colour_scheme'] = array( + $form['colour_scheme'] = [ '#type' => 'details', '#open' => TRUE, '#title' => t('Colour scheme'), - ); + ]; // Colour scheme select list. - $form['colour_scheme']['wcms_colour_scheme'] = array( + $form['colour_scheme']['wcms_colour_scheme'] = [ '#type' => 'select', '#default_value' => theme_get_setting('wcms_colour_scheme', 'uw_fdsu_theme_resp') ? theme_get_setting('wcms_colour_scheme', 'uw_fdsu_theme_resp') : 'default', '#description' => t("Select a color scheme to use"), @@ -111,7 +111,7 @@ function uw_fdsu_theme_resp_form_system_theme_settings_alter(&$form, \Drupal\Cor 'org-sci' => 'Science (blue)', 'org-school' => 'School (red)', ], - ); + ]; } /** @@ -148,7 +148,7 @@ function _uw_fdsu_theme_resp_get_field_value_from_paragraph($paragraph, $field) * - sources: An array of image sources. * - alt: The alternative text. */ -function _uw_fdsu_theme_resp_add_responsive_image_variables(array &$variables, Drupal\image\Plugin\Field\FieldType\ImageItem $field, string $responsive_image_style) : ?array { +function _uw_fdsu_theme_resp_add_responsive_image_variables(array &$variables, ImageItem $field, string $responsive_image_style) : ?array { // If there is a file present, set responsive image variables. if ($file = $field->entity) { @@ -192,7 +192,7 @@ function _uw_fdsu_theme_resp_add_responsive_image_variables(array &$variables, D * An array of image properties or NULL if $field does not contain the * required information. */ -function _uw_fdsu_theme_resp_get_image_info(Drupal\file\Plugin\Field\FieldType\FileFieldItemList $field) { +function _uw_fdsu_theme_resp_get_image_info(FileFieldItemList $field) { // If there is an image, process it. if ($img_entity = $field->first()) {