You are here

public function UserRestrictionTypeManager::getTypes in User restrictions 8

Get a list of all registered plugin instances.

Return value

\Drupal\user_restrictions\Plugin\UserRestrictionTypeInterface[] List of UserRestrictionType plugin instances.

Overrides UserRestrictionTypeManagerInterface::getTypes

2 calls to UserRestrictionTypeManager::getTypes()
UserRestrictionTypeManager::getType in src/UserRestrictionTypeManager.php
Get a single plugin instance.
UserRestrictionTypeManager::getTypesAsOptions in src/UserRestrictionTypeManager.php
Get a list of all plugins names for option lists.

File

src/UserRestrictionTypeManager.php, line 40

Class

UserRestrictionTypeManager
Manages user restriction type plugins.

Namespace

Drupal\user_restrictions

Code

public function getTypes() {
  $instances =& drupal_static(__FUNCTION__, []);
  if (empty($instances)) {

    // Get registered plugins.
    $plugins = $this
      ->getDefinitions();

    // Sort plugins by weight.
    uasort($plugins, [
      'Drupal\\Component\\Utility\\SortArray',
      'sortByWeightElement',
    ]);
    foreach ($plugins as $plugin_id => $plugin) {

      // Instanciate the plugin.
      $instances[$plugin_id] = $this
        ->createInstance($plugin_id, $plugin);
    }
  }
  return $instances;
}