Skip to content
Snippets Groups Projects

Implement CategorizingPluginManagerInterface for ComponentPluginManager.

Closes #3474533

Merge request reports

Loading
Loading

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
175 }
176
177 /**
178 * {@inheritdoc}
179 */
180 public function getSortedDefinitions(?array $definitions = NULL) {
181 // Sort the plugins first by group, then by label.
182 $definitions = $definitions ?? $this->getDefinitions();
183 uasort($definitions, static function ($a, $b) {
184 $a_group = isset($a['group']) ? (string) $a['group'] : '';
185 $b_group = isset($b['group']) ? (string) $b['group'] : '';
186 if ($a_group !== $b_group) {
187 return strnatcasecmp($a_group, $b_group);
188 }
189 $a_label = preg_replace("/[^A-Za-z0-9 ]/", '', $a['name']);
190 $b_label = preg_replace("/[^A-Za-z0-9 ]/", '', $b['name']);
  • 185 $b_group = isset($b['group']) ? (string) $b['group'] : '';
    186 if ($a_group !== $b_group) {
    187 return strnatcasecmp($a_group, $b_group);
    188 }
    189 $a_label = preg_replace("/[^A-Za-z0-9 ]/", '', $a['name']);
    190 $b_label = preg_replace("/[^A-Za-z0-9 ]/", '', $b['name']);
    191 return strnatcasecmp($a_label, $b_label);
    192 });
    193 return $definitions;
    194 }
    195
    196 /**
    197 * {@inheritdoc}
    198 */
    199 public function getGroupedDefinitions(?array $definitions = NULL) {
    200 $definitions = $definitions ?: $this->getSortedDefinitions();
  • 161 162 $this->componentNegotiator->clearCache();
    162 163 }
    163 164
    165 /**
    166 * {@inheritdoc}
    167 */
    168 public function getCategories() {
    169 // Fetch all categories from definitions and remove duplicates.
    170 $categories = array_unique(array_values(array_map(static function ($definition) {
    171 return $definition['group'] ?? t('Other');
    172 }, $this->getDefinitions())));
    • Comment on lines +170 to +172
      Suggested change
      170 $categories = array_unique(array_values(array_map(static function ($definition) {
      171 return $definition['group'] ?? t('Other');
      172 }, $this->getDefinitions())));
      170 $categories = array_map(static fn($definition) => $definition['group'] ?? t('Other'), $this->getDefinitions());
      171 $categories = array_unique(array_values($categories));
    • Please register or sign in to reply
    Please register or sign in to reply
    Loading