You are here

public function ResourceManager::getPlugins in RESTful 7.2

Gets the plugin collection for this plugin manager.

Parameters

bool $only_enabled: Only get the enabled resources. Defaults to TRUE.

Return value

ResourcePluginCollection The plugin collection.

Overrides ResourceManagerInterface::getPlugins

File

src/Resource/ResourceManager.php, line 63
Contains \Drupal\restful\Resource\ResourceManager.

Class

ResourceManager

Namespace

Drupal\restful\Resource

Code

public function getPlugins($only_enabled = TRUE) {
  if (!$only_enabled) {
    return $this->plugins;
  }
  $cloned_plugins = clone $this->plugins;
  $instance_ids = $cloned_plugins
    ->getInstanceIds();
  foreach ($instance_ids as $instance_id) {
    $plugin = NULL;
    try {
      $plugin = $cloned_plugins
        ->get($instance_id);
    } catch (UnauthorizedException $e) {
    }
    if (!$plugin instanceof ResourceInterface) {
      $cloned_plugins
        ->remove($instance_id);
      $cloned_plugins
        ->removeInstanceId($instance_id);
    }
  }
  return $cloned_plugins;
}