public function SocialMediaLinksPlatformManager::getPlatformsSortedByWeight in Social Media Links Block and Field 8.2
Get all platform plugins and sort it by weight from.
Platform settings (e.g. block configuration, field settings).
Parameters
array $settings: The configuration with the 'weight'.
Return value
array The platform plugins sorted by weight setting.
File
- src/
SocialMediaLinksPlatformManager.php, line 64
Class
- SocialMediaLinksPlatformManager
- Manager class for the platform plugins.
Namespace
Drupal\social_media_linksCode
public function getPlatformsSortedByWeight(array $settings) {
$default_weight = -10;
$platforms = $this
->getPlatforms();
foreach ($platforms as $platform_id => $platform) {
$platforms[$platform_id]['weight'] = isset($settings['platforms'][$platform_id]['weight']) ? $settings['platforms'][$platform_id]['weight'] : $default_weight++;
}
uasort($platforms, [
'Drupal\\Component\\Utility\\SortArray',
'sortByWeightElement',
]);
return $platforms;
}