AttributeCollection.php 870 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. <?php
  2. /**
  3. * @file
  4. * Contains \Drupal\linkit\AttributeCollection.
  5. */
  6. namespace Drupal\linkit;
  7. use Drupal\Core\Plugin\DefaultLazyPluginCollection;
  8. /**
  9. * A collection of attribute plugins.
  10. */
  11. class AttributeCollection extends DefaultLazyPluginCollection {
  12. /**
  13. * All possible attribute IDs.
  14. *
  15. * @var array
  16. */
  17. protected $definitions;
  18. /**
  19. * {@inheritdoc}
  20. *
  21. * @return \Drupal\linkit\AttributeInterface
  22. */
  23. public function &get($instance_id) {
  24. return parent::get($instance_id);
  25. }
  26. /**
  27. * {@inheritdoc}
  28. */
  29. public function sortHelper($aID, $bID) {
  30. $a_weight = $this->get($aID)->getWeight();
  31. $b_weight = $this->get($bID)->getWeight();
  32. if ($a_weight == $b_weight) {
  33. return strnatcasecmp($this->get($aID)->getLabel(), $this->get($bID)->getLabel());
  34. }
  35. return ($a_weight < $b_weight) ? -1 : 1;
  36. }
  37. }