MatcherCollection.php 626 B

1234567891011121314151617181920212223242526272829303132
  1. <?php
  2. namespace Drupal\linkit;
  3. use Drupal\Core\Plugin\DefaultLazyPluginCollection;
  4. /**
  5. * A collection of matchers.
  6. */
  7. class MatcherCollection extends DefaultLazyPluginCollection {
  8. /**
  9. * All possible matcher IDs.
  10. *
  11. * @var array
  12. */
  13. protected $definitions;
  14. /**
  15. * {@inheritdoc}
  16. */
  17. public function sortHelper($aID, $bID) {
  18. $a_weight = $this->get($aID)->getWeight();
  19. $b_weight = $this->get($bID)->getWeight();
  20. if ($a_weight == $b_weight) {
  21. return strnatcasecmp($this->get($aID)->getLabel(), $this->get($bID)->getLabel());
  22. }
  23. return ($a_weight < $b_weight) ? -1 : 1;
  24. }
  25. }