From e4d5ad7a8f51705d13f1d25fa0769ddf10d30c79 Mon Sep 17 00:00:00 2001 From: Liam Morland <lkmorlan@uwaterloo.ca> Date: Wed, 26 Aug 2020 10:58:13 -0400 Subject: [PATCH] Coding standards --- src/Service/UWService.php | 33 +++++++++++++++++------------- src/Service/UWServiceInterface.php | 6 +++++- uw_cfg_common.module | 7 ++++--- 3 files changed, 28 insertions(+), 18 deletions(-) diff --git a/src/Service/UWService.php b/src/Service/UWService.php index 5f0827b9..52a1e84b 100644 --- a/src/Service/UWService.php +++ b/src/Service/UWService.php @@ -3,11 +3,10 @@ namespace Drupal\uw_cfg_common\Service; use Drupal\Core\Entity\EntityInterface; -use Drupal\node\Entity\Node; use Drupal\node\NodeInterface; /** - * Class UWService + * Class UWService. * * @package Drupal\uw_cfg_common\Service */ @@ -46,14 +45,16 @@ class UWService implements UWServiceInterface { } /** - * {@inheritDoc} - */ + * {@inheritDoc} + */ public function getTeaserContent(NodeInterface $node, array $variables_to_get, string $teaser_type): array { - // Step through each of the variables to get and set the variables for the teaser content. + // Step through each of the variables to get and set the variables for the + // teaser content. foreach ($variables_to_get as $variable_to_get) { - // Switch on the variable to get and set the variables for the teaser content. + // Switch on the variable to get and set the variables for the teaser + // content. switch ($variable_to_get) { case 'title': @@ -74,8 +75,9 @@ class UWService implements UWServiceInterface { // field_uw_<content_type>_date. $field_name = 'field_uw_' . trim($teaser_type) . '_date'; - // Set the date variable, once returned to the calling function, they can - // change the date format as required (i.e. change it to long-date or date-time). + // Set the date variable, once returned to the calling function, they + // can change the date format as required (i.e. change it to long-date + // or date-time). $variables['date'] = $node->$field_name->getString(); break; @@ -104,7 +106,8 @@ class UWService implements UWServiceInterface { // Ensure that we have an image before adding variables. if ($image !== NULL) { - // Get all the image variables, including the sources using the prepareResponsiveImage function. + // Get all the image variables, including the sources using the + // prepareResponsiveImage function. $image_variables = $this->prepareResponsiveImage($image, 'uw_ris_media'); // Set the responsive image variables for the teaser content. @@ -116,7 +119,8 @@ class UWService implements UWServiceInterface { case 'tags': - // Set the field name for the tags which is field_uw_<content_type>_tags'. + // Set the field name for the tags which is + // field_uw_<content_type>_tags. $field_name = 'field_uw_' . trim($teaser_type) . '_tags'; // Get all the taxonomy terms for the blog. @@ -133,12 +137,13 @@ class UWService implements UWServiceInterface { case 'content': - // Set the field name for the summary, which is field_name<content_type>_summary. + // Set the field name for the summary, which is + // field_name<content_type>_summary. $field_name = 'field_uw_' . $teaser_type . '_summary'; - // Set the render array for the summary, we simply can not just send the - // value as Drupal will just render it with no filters or HTML applied. - // We need to send the full render array. + // Set the render array for the summary, we simply can not just send + // the value as Drupal will just render it with no filters or HTML + // applied. We need to send the full render array. $variables['content'] = [ '#type' => 'processed_text', '#text' => $node->$field_name->value, diff --git a/src/Service/UWServiceInterface.php b/src/Service/UWServiceInterface.php index 3e5d48f4..c6797003 100644 --- a/src/Service/UWServiceInterface.php +++ b/src/Service/UWServiceInterface.php @@ -4,6 +4,9 @@ namespace Drupal\uw_cfg_common\Service; use Drupal\Core\Entity\EntityInterface; +/** + * Interface for UW services. + */ interface UWServiceInterface { /** @@ -15,7 +18,8 @@ interface UWServiceInterface { * Image style to be used for responsive image. * * @return array - * Array with details for responsive image. + * Array with details for responsive image. */ public function prepareResponsiveImage(EntityInterface $entity, string $image_style): array; + } diff --git a/uw_cfg_common.module b/uw_cfg_common.module index ac283841..5cfcaf81 100644 --- a/uw_cfg_common.module +++ b/uw_cfg_common.module @@ -152,9 +152,10 @@ function uw_cfg_common_toolbar_alter(&$items) { // Get the roles of the user. $roles = $current_user->getRoles(); - // If there is only 1 role and that first role is authenticated, remove the manage link. - // If there are multiple roles then we know that they will have the Manage link, we are - // only removing the manage link for strictly authenticated users only. + // If there is only 1 role and that first role is authenticated, remove the + // manage link. If there are multiple roles then we know that they will have + // the Manage link, we are only removing the manage link for strictly + // authenticated users only. if (count($roles) == 1 && $roles[0] == 'authenticated') { // Remove the manage link. -- GitLab