b7124c2f3444a58ad9c891ab63fc8fa5c3801997
[yaffs-website] / web / modules / contrib / linkit / src / MatcherCollection.php
1 <?php
2
3 /**
4  * @file
5  * Contains \Drupal\linkit\MatcherCollection.
6  */
7
8 namespace Drupal\linkit;
9
10 use Drupal\Core\Plugin\DefaultLazyPluginCollection;
11
12 /**
13  * A collection of matchers.
14  */
15 class MatcherCollection extends DefaultLazyPluginCollection {
16
17   /**
18    * All possible matcher IDs.
19    *
20    * @var array
21    */
22   protected $definitions;
23
24   /**
25    * {@inheritdoc}
26    *
27    * @return \Drupal\linkit\MatcherInterface
28    */
29   public function &get($instance_id) {
30     return parent::get($instance_id);
31   }
32
33   /**
34    * {@inheritdoc}
35    */
36   public function sortHelper($aID, $bID) {
37     $a_weight = $this->get($aID)->getWeight();
38     $b_weight = $this->get($bID)->getWeight();
39     if ($a_weight == $b_weight) {
40       return strnatcasecmp($this->get($aID)->getLabel(), $this->get($bID)->getLabel());
41     }
42
43     return ($a_weight < $b_weight) ? -1 : 1;
44   }
45
46 }