You are here

protected function EdgeEntityType::getEntityLabelFromConfig in Apigee Edge 8

Returns entity label from config if exists.

Parameters

string $key: The config object key. It starts with "entity_label_".

Return value

string|null The entity label if the config and config key exists, null otherwise.

3 calls to EdgeEntityType::getEntityLabelFromConfig()
EdgeEntityType::getCollectionLabel in src/Entity/EdgeEntityType.php
Gets the uppercase plural form of the name of the entity type.
EdgeEntityType::getLabel in src/Entity/EdgeEntityType.php
Gets the human-readable name of the entity type.
EdgeEntityType::getPluralLabel in src/Entity/EdgeEntityType.php
Gets the indefinite plural form of the name of the entity type.

File

src/Entity/EdgeEntityType.php, line 143

Class

EdgeEntityType
Provides an implementation of an Apigee Edge entity type and its metadata.

Namespace

Drupal\apigee_edge\Entity

Code

protected function getEntityLabelFromConfig(string $key) : ?string {
  $logger = \Drupal::logger('apigee_edge');
  try {
    $config = $this
      ->getConfigWithEntityLabels();
    if ($config) {
      $label = $config
        ->get($key);
      if ($label === NULL) {
        $logger
          ->warning('@class: The "@key" has not been found in @config config object for "@entity_type" entity.', [
          '@class' => get_class($this),
          '@entity_type' => $this->id,
          '@key' => $key,
          '@config' => $this->config_with_labels ?? "apigee_edge.{$this->id}_settings",
        ]);
      }
      return $label;
    }
  } catch (RuntimeException $exception) {

    // Just catch it, do not log it, because this could generate invalid
    // log entries when the module is uninstalled.
  }
  return NULL;
}