You are here

class CampaignMonitorUserManager in Campaign Monitor 8.2

Manager for Campaignmonitor subscriptions.

Hierarchy

Expanded class hierarchy of CampaignMonitorUserManager

1 file declares its use of CampaignMonitorUserManager
CampaignMonitorUserController.php in modules/campaignmonitor_user/src/Controller/CampaignMonitorUserController.php
1 string reference to 'CampaignMonitorUserManager'
campaignmonitor_user.services.yml in modules/campaignmonitor_user/campaignmonitor_user.services.yml
modules/campaignmonitor_user/campaignmonitor_user.services.yml
1 service uses CampaignMonitorUserManager
campaignmonitor_user.manager in modules/campaignmonitor_user/campaignmonitor_user.services.yml
Drupal\campaignmonitor_user\CampaignMonitorUserManager

File

modules/campaignmonitor_user/src/CampaignMonitorUserManager.php, line 15

Namespace

Drupal\campaignmonitor_user
View source
class CampaignMonitorUserManager extends CampaignMonitorManager {

  /**
   * The campaignmonitor manager.
   *
   * @var \Drupal\campaignmonitor\CampaignMonitorManager
   */
  protected $campaignMonitorManager;

  /**
   * Drupal\Core\Config\ConfigFactoryInterface definition.
   *
   * @var \Drupal\Core\Config\ConfigFactoryInterface
   */
  protected $configFactory;

  /**
   * The language manager service.
   *
   * @var \Drupal\Core\Language\LanguageManagerInterface
   */
  protected $languageManager;

  /**
   * The module manager service.
   *
   * @var \Drupal\Core\Extension\ModuleHandlerInterface
   */
  protected $moduleHandler;

  /**
   * The current user.
   *
   * @var \Drupal\Core\Session\AccountProxyInterface
   */
  protected $account;

  /**
   * The entity type manager.
   *
   * @var \Drupal\Core\Entity\EntityTypeManagerInterface
   */
  protected $entityTypeManager;

  /**
   * The constructor.
   *
   * @param \Drupal\campaignmonitor\CampaignMonitorManager $campaignmonitor_manager
   *   The campaign monitor manager.
   * @param \Drupal\Core\Config\ConfigFactoryInterface $config_factory
   *   The config factory.
   * @param \Drupal\Core\Language\LanguageManagerInterface $language_manager
   *   The language manager service.
   * @param \Drupal\Core\Extension\ModuleHandlerInterface $module_handler
   *   The module handler.
   * @param \Drupal\Core\Session\AccountProxyInterface $account
   *   The account interface.
   * @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager
   *   The entity type manager.
   */
  public function __construct(CampaignMonitorManager $campaignmonitor_manager, ConfigFactoryInterface $config_factory, LanguageManagerInterface $language_manager, ModuleHandlerInterface $module_handler, AccountProxyInterface $account, EntityTypeManagerInterface $entity_type_manager) {
    $this->campaignMonitorManager = $campaignmonitor_manager;
    $this->languageManager = $language_manager;
    $this->moduleHandler = $module_handler;
    $this->configFactory = $config_factory;

    // Get account information.
    $this->config = $config_factory
      ->get('campaignmonitor.settings');
    $this->account = $account;
    $this->entityTypeManager = $entity_type_manager;
  }

  /**
   * Helper function to get a user's subscriptions.
   *
   * @param string $email
   *   The user mail id.
   * @param string $format
   *   Return value depends on format requested.
   *
   * @return array
   *   list names.
   */
  public function getUserSubscriptions($email, $format = 'checkboxes') {
    $lists = $this->campaignMonitorManager
      ->getLists();

    // Build options for the form selector.
    $options = [];
    $default = [];
    foreach ($lists as $list_id => $list) {

      // Check if the list is selected to be shown.
      // $list_options = $this->campaignMonitorManager
      // ->getListSettings($list_id);.
      if ($this->campaignMonitorManager
        ->isListEnabled($list_id)) {

        // Check if the user is subscribed to the current list.
        $default[$list_id] = 0;
        if ($this->campaignMonitorManager
          ->isSubscribed($list_id, $email)) {
          $default[$list_id] = $list_id;
          $options[$list_id] = $list['name'];
        }
      }
    }
    switch ($format) {
      case 'checkboxes':
        return $default;
      default:
        return $options;
    }
  }

}

Members

Namesort descending Modifiers Type Description Overrides
CampaignMonitorManager::$apiKey protected property Stores the api key.
CampaignMonitorManager::$cacheBackend protected property The cache backend service.
CampaignMonitorManager::$campaigns protected property This variable is used to store campaign data in cache.
CampaignMonitorManager::$clientId protected property Stores the client id.
CampaignMonitorManager::$config protected property Config settings.
CampaignMonitorManager::$drafts protected property This variable is used to store draft data.
CampaignMonitorManager::$errors protected property This variable stores the errors.
CampaignMonitorManager::$instance protected static property Holds the object instance (part of the singleton pattern).
CampaignMonitorManager::$lists protected property These variables are used as static cache for the object.
CampaignMonitorManager::$listStats protected property List stats.
CampaignMonitorManager::$logErrors protected property Tells if there is any log errors.
CampaignMonitorManager::$loggerFactory protected property The logger service.
CampaignMonitorManager::$subscribers protected property This variables used to store the subscriber details.
CampaignMonitorManager::addError protected function Add an error to the local stack and call watchdog, if logging is enabled.
CampaignMonitorManager::clearCache public function Clears all the caches used by this wrapper object.
CampaignMonitorManager::createClientObj public function Create API client object.
CampaignMonitorManager::createList public function Create a new list at the Campaign Monitor servers.
CampaignMonitorManager::createListObj protected function Create API list object.
CampaignMonitorManager::createSubscriberObj protected function Create API subscribers object.
CampaignMonitorManager::deleteList public function Delete a list from Campaign Monitor.
CampaignMonitorManager::getCacheTimeout protected function Create a UNIX timestamp based on the cache timeout from admin interface.
CampaignMonitorManager::getCampaigns public function Get basic information about campaigns in the form of a keyed array.
CampaignMonitorManager::getConnector public static function Implements a singleton pattern that returns an instance of this object.
CampaignMonitorManager::getCustomFields public function Fetch custom fields for a given list.
CampaignMonitorManager::getDrafts public function Get basic information about drafts in the form of a keyed array.
CampaignMonitorManager::getErrors public function Returns the internal error array with the format below.
CampaignMonitorManager::getExtendedList public function Get all information available about a given list.
CampaignMonitorManager::getLatestError public function Gets the latest error from the stack of possible errors.
CampaignMonitorManager::getListDetails public function Gets list details from Campaign Monitor.
CampaignMonitorManager::getLists public function Gets all CM lists found under the client ID given during object creation.
CampaignMonitorManager::getListSettings public function Gets the settings for a list.
CampaignMonitorManager::getListStats public function Fetch stats about a given list including subscribers and unsubscribers.
CampaignMonitorManager::getSubscriber public function Get values entered by the subscriber, when subscribing to a list.
CampaignMonitorManager::isListEnabled public function Checks if the list given by id is enabled locally.
CampaignMonitorManager::isSubscribed public function Check if user, identified by e-mail, is subscribed to a given list.
CampaignMonitorManager::listKey public function Helper function to determine config var name for list options.
CampaignMonitorManager::removeSubscriberFromCache public function Remove subscribers from local cache.
CampaignMonitorManager::resetErrors public function Resets the internal error array to an empty array.
CampaignMonitorManager::setListSettings public function Sets the config for a list.
CampaignMonitorManager::subscribe public function Subscribe a user to a given list, with information entered.
CampaignMonitorManager::unsubscribe public function Unsubscribe a given user, identified by e-mail address, from a given list.
CampaignMonitorManager::updateList public function Update remote list information.
CampaignMonitorManager::updateSubscriberEmail public function Updates the subscriber e-mail address for a given list.
CampaignMonitorUserManager::$account protected property The current user.
CampaignMonitorUserManager::$campaignMonitorManager protected property The campaignmonitor manager.
CampaignMonitorUserManager::$configFactory protected property Drupal\Core\Config\ConfigFactoryInterface definition. Overrides CampaignMonitorManager::$configFactory
CampaignMonitorUserManager::$entityTypeManager protected property The entity type manager.
CampaignMonitorUserManager::$languageManager protected property The language manager service. Overrides CampaignMonitorManager::$languageManager
CampaignMonitorUserManager::$moduleHandler protected property The module manager service. Overrides CampaignMonitorManager::$moduleHandler
CampaignMonitorUserManager::getUserSubscriptions public function Helper function to get a user's subscriptions.
CampaignMonitorUserManager::__construct public function The constructor. Overrides CampaignMonitorManager::__construct
StringTranslationTrait::$stringTranslation protected property The string translation service. 1
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.