public function WebformHandlerPluginCollection::sortHelper in Webform 6.x
Same name and namespace in other branches
- 8.5 src/Plugin/WebformHandlerPluginCollection.php \Drupal\webform\Plugin\WebformHandlerPluginCollection::sortHelper()
Provides uasort() callback to sort plugins.
Overrides DefaultLazyPluginCollection::sortHelper
File
- src/
Plugin/ WebformHandlerPluginCollection.php, line 16
Class
- WebformHandlerPluginCollection
- A collection of webform handlers.
Namespace
Drupal\webform\PluginCode
public function sortHelper($a_id, $b_id) {
/** @var \Drupal\webform\Plugin\WebformHandlerInterface $a */
$a = $this
->get($a_id);
/** @var \Drupal\webform\Plugin\WebformHandlerInterface $b */
$b = $this
->get($b_id);
$a_weight = $a
->getWeight();
$b_weight = $b
->getWeight();
if ($a_weight === $b_weight) {
return strnatcasecmp($a
->getHandlerId(), $b
->getHandlerId());
}
return $a_weight < $b_weight ? -1 : 1;
}