You are here

public function AmpMetadataInfo::getAmpNodeTypesWithoutMetadataSettings in Accelerated Mobile Pages (AMP) 8

Returns an array of available node types to override.

Return value

array A list of available node types as $id => $label.

File

src/AmpMetadataInfo.php, line 68

Class

AmpMetadataInfo
Service class for retrieving information about AMP Metadata.

Namespace

Drupal\amp

Code

public function getAmpNodeTypesWithoutMetadataSettings() {
  $options = array();
  $amp_metadata_settings = $this->entityTypeManager
    ->getStorage('amp_metadata')
    ->loadMultiple();
  $amp_types_with_settings = [];

  /** @var AmpMetadataInterface $amp_metadata  */
  foreach ($amp_metadata_settings as $amp_metadata_id => $amp_metadata) {
    if (!$amp_metadata
      ->isGlobal()) {
      $amp_types_with_settings[] = $amp_metadata
        ->getNodeType();
    }
  }
  $amp_enabled_node_types = $this->entityTypeInfo
    ->getAmpEnabledTypes();
  foreach ($amp_enabled_node_types as $node_type) {
    if (!in_array($node_type, $amp_types_with_settings)) {
      $options[$node_type] = $this->entityTypeManager
        ->getStorage('node_type')
        ->load($node_type)
        ->label();
    }
  }
  return $options;
}