Updated to Drupal 8.5. Core Media not yet in use.
[yaffs-website] / web / modules / contrib / metatag / src / MetatagDefaultsListBuilder.php
index e8df1b5ae0bbdcdd0e8f2b74a60fd83bea7b872c..3811665f091b5a05a512b4de1af8bf74468844d0 100644 (file)
@@ -15,8 +15,15 @@ class MetatagDefaultsListBuilder extends ConfigEntityListBuilder {
    */
   public function load() {
     $entities = parent::load();
-    // Move the Global defaults to the top.
-    return ['global' => $entities['global']] + $entities;
+
+    // Move the Global defaults to the top. Don't assume that the global config
+    // exists, it might have been removed.
+    if (isset($entities['global'])) {
+      return ['global' => $entities['global']] + $entities;
+    }
+    else {
+      return $entities;
+    }
   }
 
   /**
@@ -41,11 +48,8 @@ class MetatagDefaultsListBuilder extends ConfigEntityListBuilder {
   public function getOperations(EntityInterface $entity) {
     $operations = parent::getOperations($entity);
 
-    // Set the defaults that should not be deletable
-    $protected_defaults = ['global', '403', '404', 'node', 'front', 'taxonomy_term', 'user'];
-
     // Global and entity defaults can be reverted but not deleted.
-    if (in_array($entity->id(), $protected_defaults)) {
+    if (in_array($entity->id(), MetatagManager::protectedDefaults())) {
       unset($operations['delete']);
       $operations['revert'] = [
         'title' => t('Revert'),
@@ -60,10 +64,10 @@ class MetatagDefaultsListBuilder extends ConfigEntityListBuilder {
   /**
    * Renders the Metatag defaults label plus its configuration.
    *
-   * @param EntityInterface $entity
+   * @param Drupal\Core\Entity\EntityInterface $entity
    *   The Metatag defaults entity.
    *
-   * @return
+   * @return array
    *   Render array for a table cell.
    */
   public function getLabelAndConfig(EntityInterface $entity) {
@@ -81,12 +85,14 @@ class MetatagDefaultsListBuilder extends ConfigEntityListBuilder {
     }
 
     if (!empty($inherits)) {
-      $output .= '<div><p>' . t('Inherits meta tags from: @inherits', ['@inherits' => $inherits]) . '</p></div>';
+      $output .= '<div><p>' . t('Inherits meta tags from: @inherits', [
+        '@inherits' => $inherits,
+      ]) . '</p></div>';
     }
     $tags = $entity->get('tags');
     if (count($tags)) {
       $output .= '<table>
-                    <tbody>';
+<tbody>';
       foreach ($tags as $tag_id => $tag_value) {
         $output .= '<tr><td>' . $tag_id . ':</td><td>' . $tag_value . '</td></tr>';
       }