You are here

public static function InsertUtility::aggregateStyles in Insert 8.2

Parameters

string $insertType:

Return value

array

2 calls to InsertUtility::aggregateStyles()
insert_field_widget_settings_summary_alter in ./insert.module
Implements hook_field_widget_settings_summary_alter().
_insert_settings_form in ./insert.module

File

src/Utility/InsertUtility.php, line 52

Class

InsertUtility

Namespace

Drupal\insert\Utility

Code

public static function aggregateStyles($insertType) {
  $styles = \Drupal::moduleHandler()
    ->invokeAll('insert_styles', [
    $insertType,
  ]);
  uasort($styles, function ($a, $b) {
    $weightA = !$a instanceof ImageStyle && isset($a['weight']) ? $a['weight'] : 0;
    $weightB = !$b instanceof ImageStyle && isset($b['weight']) ? $b['weight'] : 0;
    if ($weightA === 0 && $weightB === 0) {
      $labelA = $a instanceof ImageStyle ? $a
        ->label() : $a['label'];
      $labelB = $b instanceof ImageStyle ? $b
        ->label() : $b['label'];
      return strcasecmp($labelA, $labelB);
    }
    return $weightA < $weightB ? -1 : 1;
  });
  return $styles;
}