You are here

public function HelperService::getDisplayConfig in Weather 8

Same name and namespace in other branches
  1. 2.0.x src/Service/HelperService.php \Drupal\weather\Service\HelperService::getDisplayConfig()

Return display configuration for a specific display.

If there is no configuration yet, get the default configuration instead.

Parameters

string $display_type: Display type.

int $display_number: Display number.

Return value

array Display configuration.

File

src/Service/HelperService.php, line 71

Class

HelperService
HelperService service.

Namespace

Drupal\weather\Service

Code

public function getDisplayConfig($display_type, $display_number = NULL) {

  // Set default config.
  $config = $this
    ->getDefaultConfig();

  // Try to find configuration for the display in DB.
  $display_number = $display_number != NULL ? $display_number : 1;
  $display = $this->weatherDisplayStorage
    ->loadByProperties([
    'type' => $display_type,
    'number' => $display_number,
  ]);
  $display = reset($display);
  if ($display instanceof WeatherDisplayInterface) {
    $config = $display->config
      ->getValue()[0];
  }
  return $config;
}