Updated all the contrib modules to their latest versions.
[yaffs-website] / web / modules / contrib / metatag / src / Entity / MetatagDefaults.php
index 17c3ad4965057441112107a5f9be62ab6be9d314..da9a8efbbdf4093f2fa10a6ad413bde5e9bee7a2 100644 (file)
@@ -3,6 +3,7 @@
 namespace Drupal\metatag\Entity;
 
 use Drupal\Core\Config\Entity\ConfigEntityBase;
+use Drupal\Core\Config\Entity\ConfigEntityInterface;
 use Drupal\Core\Config\FileStorage;
 use Drupal\Core\Config\InstallStorage;
 use Drupal\Core\Config\StorageInterface;
@@ -120,4 +121,26 @@ class MetatagDefaults extends ConfigEntityBase implements MetatagDefaultsInterfa
     }
   }
 
+  /**
+   * {@inheritdoc}
+   */
+  public static function sort(ConfigEntityInterface $a, ConfigEntityInterface $b) {
+    // Put always Global in 1st place and front page later if available.
+    if ($a->id() == 'global') {
+      return -1;
+    }
+    elseif ($b->id() == 'global') {
+      return 1;
+    }
+    elseif ($a->id() == 'front') {
+      return -1;
+    }
+    elseif ($b->id() == 'front') {
+      return 1;
+    }
+
+    // Use the default sort function.
+    return parent::sort($a, $b);
+  }
+
 }