You are here

class UserGroupMemberships in Open Social 10.0.x

Same name and namespace in other branches
  1. 8.9 modules/social_features/social_user_export/src/Plugin/UserExportPlugin/UserGroupMemberships.php \Drupal\social_user_export\Plugin\UserExportPlugin\UserGroupMemberships
  2. 8.4 modules/social_features/social_user_export/src/Plugin/UserExportPlugin/UserGroupMemberships.php \Drupal\social_user_export\Plugin\UserExportPlugin\UserGroupMemberships
  3. 8.5 modules/social_features/social_user_export/src/Plugin/UserExportPlugin/UserGroupMemberships.php \Drupal\social_user_export\Plugin\UserExportPlugin\UserGroupMemberships
  4. 8.6 modules/social_features/social_user_export/src/Plugin/UserExportPlugin/UserGroupMemberships.php \Drupal\social_user_export\Plugin\UserExportPlugin\UserGroupMemberships
  5. 8.7 modules/social_features/social_user_export/src/Plugin/UserExportPlugin/UserGroupMemberships.php \Drupal\social_user_export\Plugin\UserExportPlugin\UserGroupMemberships
  6. 8.8 modules/social_features/social_user_export/src/Plugin/UserExportPlugin/UserGroupMemberships.php \Drupal\social_user_export\Plugin\UserExportPlugin\UserGroupMemberships
  7. 10.3.x modules/social_features/social_user_export/src/Plugin/UserExportPlugin/UserGroupMemberships.php \Drupal\social_user_export\Plugin\UserExportPlugin\UserGroupMemberships
  8. 10.1.x modules/social_features/social_user_export/src/Plugin/UserExportPlugin/UserGroupMemberships.php \Drupal\social_user_export\Plugin\UserExportPlugin\UserGroupMemberships
  9. 10.2.x modules/social_features/social_user_export/src/Plugin/UserExportPlugin/UserGroupMemberships.php \Drupal\social_user_export\Plugin\UserExportPlugin\UserGroupMemberships

Provides a 'UserGroupMemberships' user export row.

Plugin annotation


@UserExportPlugin(
 id = "user_group_memberships",
 label = @Translation("Group memberships (specified)"),
 weight = -198,
)

Hierarchy

Expanded class hierarchy of UserGroupMemberships

File

modules/social_features/social_user_export/src/Plugin/UserExportPlugin/UserGroupMemberships.php, line 23

Namespace

Drupal\social_user_export\Plugin\UserExportPlugin
View source
class UserGroupMemberships extends UserExportPluginBase {

  /**
   * The group helper service.
   *
   * @var \Drupal\social_group\SocialGroupHelperService
   */
  public $groupHelper;

  /**
   * UserExportPluginBase constructor.
   *
   * @param array $configuration
   *   A configuration array containing information about the plugin instance.
   * @param string $plugin_id
   *   The plugin_id for the plugin instance.
   * @param mixed $plugin_definition
   *   The plugin implementation definition.
   * @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager
   *   The entity type manager.
   * @param \Drupal\Core\Datetime\DateFormatterInterface $date_formatter
   *   The date formatter.
   * @param \Drupal\Core\Database\Connection $database
   *   The database connection.
   * @param \Drupal\social_group\SocialGroupHelperService $group_helper
   *   The group helper service.
   */
  public function __construct(array $configuration, $plugin_id, $plugin_definition, EntityTypeManagerInterface $entity_type_manager, DateFormatterInterface $date_formatter, Connection $database, SocialGroupHelperService $group_helper) {
    parent::__construct($configuration, $plugin_id, $plugin_definition, $entity_type_manager, $date_formatter, $database);
    $this->groupHelper = $group_helper;
  }

  /**
   * The create method.
   *
   * @param \Symfony\Component\DependencyInjection\ContainerInterface $container
   *   Container interface.
   * @param array $configuration
   *   An array of configuration.
   * @param string $plugin_id
   *   The plugin id.
   * @param mixed $plugin_definition
   *   The plugin definition.
   *
   * @return \Drupal\Core\Plugin\ContainerFactoryPluginInterface|\Drupal\social_user_export\Plugin\UserExportPluginBase
   *   Returns the UserExportPluginBase.
   */
  public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) {
    return new static($configuration, $plugin_id, $plugin_definition, $container
      ->get('entity_type.manager'), $container
      ->get('date.formatter'), $container
      ->get('database'), $container
      ->get('social_group.helper_service'));
  }

  /**
   * {@inheritdoc}
   */
  public function getHeader() {
    return $this
      ->t('Group memberships (specified)');
  }

  /**
   * {@inheritdoc}
   */
  public function getValue(UserInterface $entity) {
    $group_memberships = Group::loadMultiple($this->groupHelper
      ->getAllGroupsForUser($entity
      ->id()));
    $groups = [];
    foreach ($group_memberships as $group) {
      $groups[] = "{$group->label()} ({$group->id()})";
    }
    return implode(', ', $groups);
  }

}

Members

Namesort descending Modifiers Type Description Overrides
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.
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.
UserExportPluginBase::$database public property The database.
UserExportPluginBase::$dateFormatter public property The date formatter.
UserExportPluginBase::$entityTypeManager public property The entity type manager.
UserExportPluginBase::getProfile public function Get the Profile entity. Overrides UserExportPluginInterface::getProfile
UserExportPluginBase::profileGetAddressFieldValue public function Returns the value for the address field and element within address. Overrides UserExportPluginInterface::profileGetAddressFieldValue
UserExportPluginBase::profileGetFieldValue public function Returns the value of a field for a given profile. Overrides UserExportPluginInterface::profileGetFieldValue
UserExportPluginBase::profileGetTaxonomyFieldValue public function Returns the values of a taxonomy reference field. Overrides UserExportPluginInterface::profileGetTaxonomyFieldValue
UserGroupMemberships::$groupHelper public property The group helper service.
UserGroupMemberships::create public static function The create method. Overrides UserExportPluginBase::create
UserGroupMemberships::getHeader public function Returns the header. Overrides UserExportPluginBase::getHeader
UserGroupMemberships::getValue public function Returns the value. Overrides UserExportPluginBase::getValue
UserGroupMemberships::__construct public function UserExportPluginBase constructor. Overrides UserExportPluginBase::__construct