Skip to content
Snippets Groups Projects
Commit 8399c2d3 authored by Eric Bremner's avatar Eric Bremner
Browse files

ISTWCMS-3558: coding standards

parent e77a7216
No related branches found
No related tags found
No related merge requests found
...@@ -96,6 +96,7 @@ function uw_fdsu_theme_resp_form_system_theme_settings_alter(&$form, \Drupal\Cor ...@@ -96,6 +96,7 @@ function uw_fdsu_theme_resp_form_system_theme_settings_alter(&$form, \Drupal\Cor
* The field value. * The field value.
*/ */
function _uw_fdsu_theme_resp_get_field_value_from_paragraph($paragraph, $field) { function _uw_fdsu_theme_resp_get_field_value_from_paragraph($paragraph, $field) {
// Get the field value. // Get the field value.
$field_value = $paragraph->get($field)->first(); $field_value = $paragraph->get($field)->first();
...@@ -118,8 +119,10 @@ function _uw_fdsu_theme_resp_get_field_value_from_paragraph($paragraph, $field) ...@@ -118,8 +119,10 @@ function _uw_fdsu_theme_resp_get_field_value_from_paragraph($paragraph, $field)
* - alt: The alternative text. * - 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, Drupal\image\Plugin\Field\FieldType\ImageItem $field, string $responsive_image_style) : ?array {
// If there is a file present, set responsive image variables. // If there is a file present, set responsive image variables.
if ($file = $field->entity) { if ($file = $field->entity) {
// Set uri and image style id. // Set uri and image style id.
$variables['uri'] = $file->getFileUri(); $variables['uri'] = $file->getFileUri();
$variables['responsive_image_style_id'] = $responsive_image_style; $variables['responsive_image_style_id'] = $responsive_image_style;
...@@ -131,7 +134,9 @@ function _uw_fdsu_theme_resp_add_responsive_image_variables(array &$variables, D ...@@ -131,7 +134,9 @@ function _uw_fdsu_theme_resp_add_responsive_image_variables(array &$variables, D
// Step through each source and get string values. // Step through each source and get string values.
$sources = []; $sources = [];
foreach ($variables['sources'] as $source) { foreach ($variables['sources'] as $source) {
$sources[] = [ $sources[] = [
'srcset' => $source['srcset']->value(), 'srcset' => $source['srcset']->value(),
'media' => $source['media']->value(), 'media' => $source['media']->value(),
...@@ -158,10 +163,13 @@ function _uw_fdsu_theme_resp_add_responsive_image_variables(array &$variables, D ...@@ -158,10 +163,13 @@ function _uw_fdsu_theme_resp_add_responsive_image_variables(array &$variables, D
* required information. * 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(Drupal\file\Plugin\Field\FieldType\FileFieldItemList $field) {
// If there is an image, process it. // If there is an image, process it.
if ($img_entity = $field->first()) { if ($img_entity = $field->first()) {
// If we can load a file, grab the info about the file. // If we can load a file, grab the info about the file.
if ($file_entity = $img_entity->get('entity')->getTarget()) { if ($file_entity = $img_entity->get('entity')->getTarget()) {
return [ return [
'src' => file_create_url($file_entity->get('uri')->getString()), 'src' => file_create_url($file_entity->get('uri')->getString()),
'alt' => $img_entity->get('alt')->getString(), 'alt' => $img_entity->get('alt')->getString(),
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment