Skip to content

Commit

Permalink
OEL-477: Some changes done.
Browse files Browse the repository at this point in the history
  • Loading branch information
Maxfire committed Dec 3, 2021
1 parent 26b2f11 commit d261b37
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 14 deletions.
1 change: 1 addition & 0 deletions modules/oe_whitelabel_helper/oe_whitelabel_helper.module
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
declare(strict_types = 1);

use Drupal\Core\Render\Element;
use Drupal\Core\Template\Attribute;

/**
* Implements hook_locale_translation_projects_alter().
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types = 1);

namespace Drupal\oe_whitelabel_helper\Plugin\field_group\FieldGroupFormatter;

use Drupal\Component\Utility\Xss;
Expand Down Expand Up @@ -94,20 +96,18 @@ public static function create(ContainerInterface $container, array $configuratio
/**
* {@inheritdoc}
*/
public static function defaultContextSettings($context) {
$defaults = [
public static function defaultContextSettings($context): array {
return [
'first_column' => '',
'second_column' => '',
'hide_table_if_empty' => FALSE,
] + parent::defaultSettings($context);

return $defaults;
}

/**
* {@inheritdoc}
*/
public function settingsForm() {
public function settingsForm(): array {
$form = parent::settingsForm();

$form['first_column'] = [
Expand Down Expand Up @@ -136,7 +136,7 @@ public function settingsForm() {
/**
* {@inheritdoc}
*/
public function settingsSummary() {
public function settingsSummary(): array {
$summary = parent::settingsSummary();
$summary[] = $this->t('Display results as a 2 column table.');

Expand All @@ -146,7 +146,7 @@ public function settingsSummary() {
/**
* {@inheritdoc}
*/
public function preRender(&$element, $rendering_object) {
public function preRender(&$element, $rendering_object): void {
parent::preRender($element, $rendering_object);

$element['#mode'] = $this->context;
Expand Down Expand Up @@ -216,7 +216,7 @@ public function preRender(&$element, $rendering_object) {
* @return array
* Table row definition on success or an empty array otherwise.
*/
protected function buildRow(array $element, $field_name) {
protected function buildRow(array $element, string $field_name): array {
$item = $this->getRowItem($element, $field_name);
$build = [];

Expand All @@ -240,13 +240,13 @@ protected function buildRow(array $element, $field_name) {
* @return array
* Item definition array on success or empty array otherwise.
*/
protected function getRowItem(array $element, $field_name) {
$item = isset($element[$field_name]) ? $element[$field_name] : [];
protected function getRowItem(array $element, string $field_name): array {
$item = $element[$field_name] ?? [];
$is_empty = !is_array($item) || !array_intersect($this->renderApiProperties, array_keys($item));

if ($is_empty && $this->getSetting('always_show_field_value') && isset($element['#entity_type'], $element['#bundle'])) {
$field_definitions = $this->entityFieldManager->getFieldDefinitions($element['#entity_type'], $element['#bundle']);
$field_definition = isset($field_definitions[$field_name]) ? $field_definitions[$field_name] : NULL;
$field_definition = $field_definitions[$field_name] ?? NULL;

if ($field_definition instanceof FieldConfigInterface) {
$is_empty = FALSE;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
{%
set title_classes = [
'field__label',
'fw-bold',
'col-12',
'col-md-6',
label_display == 'visually_hidden' ? 'visually-hidden',
Expand Down
4 changes: 2 additions & 2 deletions oe_whitelabel.theme
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ function oe_whitelabel_preprocess(&$variables) {
* Implements hook_preprocess().
*/
function oe_whitelabel_preprocess_pattern_card(array &$variables): void {
if ($variables['variant'] != 'user_profile') {
if ($variables['variant'] !== 'user_profile') {
return;
}

Expand Down Expand Up @@ -171,7 +171,7 @@ function oe_whitelabel_preprocess_pattern_card(array &$variables): void {
$variables['subtitle'] = [
'content' => $variables['subtitle'],
'tag' => "div",
'classes' => "mb-4 mt-4",
'classes' => "mb-4 mt-4 text-muted",
];

$variables['image'] = [
Expand Down

0 comments on commit d261b37

Please sign in to comment.