Implement CategorizingPluginManagerInterface for ComponentPluginManager.
3 open threads
Closes #3474533
Merge request reports
Activity
added 203 commits
-
70e255f1...35044e45 - 202 commits from branch
project:11.x
- 4761bc12 - Implement CategorizingPluginManagerInterface for ComponentPluginManager.
-
70e255f1...35044e45 - 202 commits from branch
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(); - Edited by Dave Long
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
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