/** * {@inheritdoc} */ public function getDefinitions() { $definitions = parent::getDefinitions(); if (!\Drupal::moduleHandler()->moduleExists('imce') || !imce_access()) { unset($definitions['imce']); } return $definitions; }
/** * Gets the definition of all or filtered plugins for this type. * * @param mixed $type * A string or an array of types to filter on. * * @return mixed * An array of plugin definitions. Keys are plugin IDs. */ public function getDefinitions($type = NULL) { $definitions = parent::getDefinitions(); // Filter widgets to keep only required types. if (!empty($type)) { foreach ($definitions as $widgetId => $widgetInfo) { if (is_array($type) && !in_array($widgetInfo['type'], $type) || is_string($type) && $widgetInfo['type'] !== $type) { unset($definitions[$widgetId]); } } } return $definitions; }
/** * {@inheritdoc} */ public function getDefinitions() { $definitions = parent::getDefinitions(); $count = 0; foreach ($definitions as &$definition) { if (isset($definition['weight'])) { // Add some micro weight. $definition['weight'] += $count++ * 1.0E-6; } } return $definitions; }
/** * {@inheritdoc} */ public function getDefinitions() { $methods = parent::getDefinitions(); uasort($methods, 'Drupal\\Component\\Utility\\SortArray::sortByWeightElement'); return $methods; }
/** * {@inheritdoc} */ public function getDefinitions($sorted = TRUE) { $definitions = parent::getDefinitions(); if ($sorted) { uasort($definitions, ['\\Drupal\\Component\\Utility\\SortArray', 'sortByWeightElement']); } return $definitions; }