public function PackageTypeManager::getDefinitionsByShippingMethod in Commerce Shipping 8.2
Gets the definitions for the given shipping method plugin ID.
Parameters
string $shipping_method: The shipping method plugin ID.
Return value
array The definitions.
Overrides PackageTypeManagerInterface::getDefinitionsByShippingMethod
File
- src/
PackageTypeManager.php, line 97
Class
- PackageTypeManager
- Manages discovery and instantiation of package type plugins.
Namespace
Drupal\commerce_shippingCode
public function getDefinitionsByShippingMethod($shipping_method) {
$definitions = $this
->getDefinitions();
foreach ($definitions as $id => $definition) {
if (!empty($definition['shipping_method']) && $definition['shipping_method'] != $shipping_method) {
unset($definitions[$id]);
}
}
uasort($definitions, function ($a, $b) {
return strnatcasecmp($a['label'], $b['label']);
});
return $definitions;
}