You are here

class PubSubModuleStatusChecker in Acquia Content Hub 8.2

Utility class; encapsulates static general-purpose methods.

@package Drupal\acquia_contenthub

Hierarchy

Expanded class hierarchy of PubSubModuleStatusChecker

4 files declare their use of PubSubModuleStatusChecker
PruneImportedEntitiesFromExport.php in modules/acquia_contenthub_subscriber/src/EventSubscriber/PrunePublishEntities/PruneImportedEntitiesFromExport.php
PruneImportedEntitiesFromExportTest.php in tests/src/Kernel/EventSubscriber/ExportUnownedContentOnDualConfigSites/PruneImportedEntitiesFromExportTest.php
PublisherSubscriberStatusCdfAttribute.php in src/EventSubscriber/CdfAttributes/PublisherSubscriberStatusCdfAttribute.php
PublisherSubscriberStatusCdfAttributeTest.php in tests/src/Unit/EventSubscriber/CdfAttributes/PublisherSubscriberStatusCdfAttributeTest.php
1 string reference to 'PubSubModuleStatusChecker'
acquia_contenthub.services.yml in ./acquia_contenthub.services.yml
acquia_contenthub.services.yml
1 service uses PubSubModuleStatusChecker
pub.sub_status.checker in ./acquia_contenthub.services.yml
Drupal\acquia_contenthub\PubSubModuleStatusChecker

File

src/PubSubModuleStatusChecker.php, line 12

Namespace

Drupal\acquia_contenthub
View source
class PubSubModuleStatusChecker {
  public const ACQUIA_CONTENTHUB_PUBLISHER_MODULE_ID = 'acquia_contenthub_publisher';
  public const ACQUIA_CONTENTHUB_SUBSCRIBER_MODULE_ID = 'acquia_contenthub_subscriber';

  /**
   * Module handler.
   *
   * @var \Drupal\Core\Extension\ModuleHandler
   */
  protected $moduleHandlerService;

  /**
   * PubSubModuleStatusChecker constructor.
   *
   * @param \Drupal\Core\Extension\ModuleHandler $module_handler_service
   *   Module Handler Service.
   */
  public function __construct(ModuleHandler $module_handler_service) {
    $this->moduleHandlerService = $module_handler_service;
  }

  /**
   * Determines if publisher module is installed and enabled.
   *
   * @return bool
   *   Is the module enabled?
   */
  public function isPublisher() : bool {
    return $this
      ->moduleEnabled(self::ACQUIA_CONTENTHUB_PUBLISHER_MODULE_ID);
  }

  /**
   * Determines if subscriber module is installed and enabled.
   *
   * @return bool
   *   Is the module enabled?
   */
  public function isSubscriber() : bool {
    return $this
      ->moduleEnabled(self::ACQUIA_CONTENTHUB_SUBSCRIBER_MODULE_ID);
  }

  /**
   * Checks if site has dual configuration (pub/sub).
   *
   * @return bool
   *   Are both modules enabled?
   */
  public function siteHasDualConfiguration() : bool {
    return $this
      ->isSubscriber() && $this
      ->isPublisher();
  }

  /**
   * Determines if a module is installed and enabled.
   *
   * @param string $module_id
   *   Id of the module.
   *
   * @return bool
   *   Does the module exist?
   */
  private function moduleEnabled(string $module_id) : bool {
    return $this->moduleHandlerService
      ->moduleExists($module_id);
  }

}

Members

Namesort descending Modifiers Type Description Overrides
PubSubModuleStatusChecker::$moduleHandlerService protected property Module handler.
PubSubModuleStatusChecker::ACQUIA_CONTENTHUB_PUBLISHER_MODULE_ID public constant
PubSubModuleStatusChecker::ACQUIA_CONTENTHUB_SUBSCRIBER_MODULE_ID public constant
PubSubModuleStatusChecker::isPublisher public function Determines if publisher module is installed and enabled.
PubSubModuleStatusChecker::isSubscriber public function Determines if subscriber module is installed and enabled.
PubSubModuleStatusChecker::moduleEnabled private function Determines if a module is installed and enabled.
PubSubModuleStatusChecker::siteHasDualConfiguration public function Checks if site has dual configuration (pub/sub).
PubSubModuleStatusChecker::__construct public function PubSubModuleStatusChecker constructor.