You are here

class ModulesInstalled in Open Social 10.3.x

Same name and namespace in other branches
  1. 8.9 modules/custom/social_lets_connect/modules/social_lets_connect_usage/src/Plugin/ShareUsageDataPlugin/ModulesInstalled.php \Drupal\social_lets_connect_usage\Plugin\ShareUsageDataPlugin\ModulesInstalled
  2. 8.5 modules/custom/social_lets_connect/modules/social_lets_connect_usage/src/Plugin/ShareUsageDataPlugin/ModulesInstalled.php \Drupal\social_lets_connect_usage\Plugin\ShareUsageDataPlugin\ModulesInstalled
  3. 8.6 modules/custom/social_lets_connect/modules/social_lets_connect_usage/src/Plugin/ShareUsageDataPlugin/ModulesInstalled.php \Drupal\social_lets_connect_usage\Plugin\ShareUsageDataPlugin\ModulesInstalled
  4. 8.7 modules/custom/social_lets_connect/modules/social_lets_connect_usage/src/Plugin/ShareUsageDataPlugin/ModulesInstalled.php \Drupal\social_lets_connect_usage\Plugin\ShareUsageDataPlugin\ModulesInstalled
  5. 8.8 modules/custom/social_lets_connect/modules/social_lets_connect_usage/src/Plugin/ShareUsageDataPlugin/ModulesInstalled.php \Drupal\social_lets_connect_usage\Plugin\ShareUsageDataPlugin\ModulesInstalled
  6. 10.0.x modules/custom/social_lets_connect/modules/social_lets_connect_usage/src/Plugin/ShareUsageDataPlugin/ModulesInstalled.php \Drupal\social_lets_connect_usage\Plugin\ShareUsageDataPlugin\ModulesInstalled
  7. 10.1.x modules/custom/social_lets_connect/modules/social_lets_connect_usage/src/Plugin/ShareUsageDataPlugin/ModulesInstalled.php \Drupal\social_lets_connect_usage\Plugin\ShareUsageDataPlugin\ModulesInstalled
  8. 10.2.x modules/custom/social_lets_connect/modules/social_lets_connect_usage/src/Plugin/ShareUsageDataPlugin/ModulesInstalled.php \Drupal\social_lets_connect_usage\Plugin\ShareUsageDataPlugin\ModulesInstalled

Provides a 'ModulesInstalled' share usage data plugin.

Plugin annotation


@ShareUsageDataPlugin(
 id = "modules_installed",
 label = @Translation("Modules installed"),
 setting = "modules_installed",
 weight = -420,
)

Hierarchy

Expanded class hierarchy of ModulesInstalled

File

modules/custom/social_lets_connect/modules/social_lets_connect_usage/src/Plugin/ShareUsageDataPlugin/ModulesInstalled.php, line 17

Namespace

Drupal\social_lets_connect_usage\Plugin\ShareUsageDataPlugin
View source
class ModulesInstalled extends ShareUsageDataPluginBase {

  /**
   * Get the value.
   *
   * @return array
   *   $json array.
   */
  public function getValue() {
    $value = [];
    $modules = \Drupal::service('extension.list.module')
      ->reset()
      ->getList();
    $modules = $this
      ->getExtensionsInfo($modules);
    $theme_data = \Drupal::service('theme_handler')
      ->rebuildThemeData();
    $themes = $this
      ->getExtensionsInfo($theme_data);
    $profiles = \Drupal::service('extension.list.profile')
      ->reset()
      ->getList();
    $profiles = $this
      ->getExtensionsInfo($profiles);
    $value['modules'] = $modules;
    $value['profiles'] = $profiles;
    $value['themes'] = [
      'themes' => $themes,
      'default' => \Drupal::service('theme_handler')
        ->getDefault(),
    ];
    return $value;
  }

  /**
   * Get safe extensions info.
   *
   * @param \Drupal\Core\Extension\Extension[] $projects
   *   An array of extensions.
   *
   * @return array
   *   Returns an array of projects with safe values.
   */
  private function getExtensionsInfo(array $projects) {
    $value = [];
    uasort($projects, 'system_sort_modules_by_info_name');

    /** @var \Drupal\Core\Extension\Extension $project */
    foreach ($projects as $project) {
      $name = $project
        ->getName();
      $info = $project->info;
      unset($info['dependencies']);
      $value[$name] = [
        'type' => $project
          ->getType(),
        'name' => $name,
        'status' => $project->status,
        'origin' => $project->origin,
        'info' => $info,
      ];
    }
    return $value;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
ModulesInstalled::getExtensionsInfo private function Get safe extensions info.
ModulesInstalled::getValue public function Get the value. Overrides ShareUsageDataPluginBase::getValue
PluginBase::$configuration protected property Configuration information passed into the plugin. 1
PluginBase::$pluginDefinition protected property The plugin implementation definition. 1
PluginBase::$pluginId protected property The plugin_id.
PluginBase::DERIVATIVE_SEPARATOR constant A string which is used to separate base plugin IDs from the derivative ID.
PluginBase::getBaseId public function Gets the base_plugin_id of the plugin instance. Overrides DerivativeInspectionInterface::getBaseId
PluginBase::getDerivativeId public function Gets the derivative_id of the plugin instance. Overrides DerivativeInspectionInterface::getDerivativeId
PluginBase::getPluginDefinition public function Gets the definition of the plugin implementation. Overrides PluginInspectionInterface::getPluginDefinition 2
PluginBase::getPluginId public function Gets the plugin_id of the plugin instance. Overrides PluginInspectionInterface::getPluginId
PluginBase::isConfigurable public function Determines if the plugin is configurable.
ShareUsageDataPluginBase::$config public property The config.
ShareUsageDataPluginBase::$entityTypeManager public property The entity type manager.
ShareUsageDataPluginBase::create public static function The create method. Overrides ContainerFactoryPluginInterface::create
ShareUsageDataPluginBase::enabled public function Check if this plugin should be enabled. Overrides ShareUsageDataPluginInterface::enabled
ShareUsageDataPluginBase::__construct public function UserExportPluginBase constructor. Overrides PluginBase::__construct
StringTranslationTrait::$stringTranslation protected property The string translation service. 4
StringTranslationTrait::formatPlural protected function Formats a string containing a count of items.
StringTranslationTrait::getNumberOfPlurals protected function Returns the number of plurals supported by a given language.
StringTranslationTrait::getStringTranslation protected function Gets the string translation service.
StringTranslationTrait::setStringTranslation public function Sets the string translation service to use. 2
StringTranslationTrait::t protected function Translates a string to the current language or to a given language.