You are here

class LingotekModerationFactory in Lingotek Translation 3.4.x

Same name and namespace in other branches
  1. 8.2 src/Moderation/LingotekModerationFactory.php \Drupal\lingotek\Moderation\LingotekModerationFactory
  2. 4.0.x src/Moderation/LingotekModerationFactory.php \Drupal\lingotek\Moderation\LingotekModerationFactory
  3. 3.0.x src/Moderation/LingotekModerationFactory.php \Drupal\lingotek\Moderation\LingotekModerationFactory
  4. 3.1.x src/Moderation/LingotekModerationFactory.php \Drupal\lingotek\Moderation\LingotekModerationFactory
  5. 3.2.x src/Moderation/LingotekModerationFactory.php \Drupal\lingotek\Moderation\LingotekModerationFactory
  6. 3.3.x src/Moderation/LingotekModerationFactory.php \Drupal\lingotek\Moderation\LingotekModerationFactory
  7. 3.5.x src/Moderation/LingotekModerationFactory.php \Drupal\lingotek\Moderation\LingotekModerationFactory
  8. 3.6.x src/Moderation/LingotekModerationFactory.php \Drupal\lingotek\Moderation\LingotekModerationFactory
  9. 3.7.x src/Moderation/LingotekModerationFactory.php \Drupal\lingotek\Moderation\LingotekModerationFactory
  10. 3.8.x src/Moderation/LingotekModerationFactory.php \Drupal\lingotek\Moderation\LingotekModerationFactory

A facade for getting the services that are part of moderation integrations.

@package Drupal\lingotek\Moderation

Hierarchy

Expanded class hierarchy of LingotekModerationFactory

1 file declares its use of LingotekModerationFactory
LingotekModerationFactoryTest.php in tests/src/Unit/Moderation/LingotekModerationFactoryTest.php
1 string reference to 'LingotekModerationFactory'
lingotek.services.yml in ./lingotek.services.yml
lingotek.services.yml
1 service uses LingotekModerationFactory
lingotek.moderation_factory in ./lingotek.services.yml
Drupal\lingotek\Moderation\LingotekModerationFactory

File

src/Moderation/LingotekModerationFactory.php, line 10

Namespace

Drupal\lingotek\Moderation
View source
class LingotekModerationFactory implements LingotekModerationFactoryInterface {

  /**
   * The collected moderation config services.
   *
   * @var LingotekModerationConfigurationServiceInterface[]
   */
  protected $config;

  /**
   * The collected moderation form settings services.
   *
   * @var LingotekModerationSettingsFormInterface[]
   */
  protected $forms;

  /**
   * The collected moderation handler services.
   *
   * @var LingotekModerationHandlerInterface[]
   */
  protected $handlers;

  /**
   * Constructs a \Drupal\lingotek\Moderation\LingotekModerationFactory object.
   */
  public function __construct() {
    $this->config = [];
    $this->forms = [];
    $this->handlers = [];
  }

  /**
   * {@inheritdoc}
   */
  public function addModerationConfiguration(LingotekModerationConfigurationServiceInterface $service, $id, $priority) {
    $this->config[$priority] = $service;
    krsort($this->config);
  }

  /**
   * {@inheritdoc}
   */
  public function addModerationForm(LingotekModerationSettingsFormInterface $service, $id, $priority) {
    $this->forms[$priority] = $service;
    krsort($this->forms);
  }

  /**
   * {@inheritdoc}
   */
  public function addModerationHandler(LingotekModerationHandlerInterface $service, $id, $priority) {
    $this->handlers[$priority] = $service;
    krsort($this->handlers);
  }

  /**
   * {@inheritdoc}
   */
  public function getModerationConfigurationService() {
    foreach ($this->config as $service) {
      if ($service
        ->applies()) {
        return $service;
      }
    }
  }

  /**
   * {@inheritdoc}
   */
  public function getModerationSettingsForm() {
    foreach ($this->forms as $service) {
      if ($service
        ->applies()) {
        return $service;
      }
    }
  }

  /**
   * {@inheritdoc}
   */
  public function getModerationHandler() {
    foreach ($this->handlers as $service) {
      if ($service
        ->applies()) {
        return $service;
      }
    }
  }

}

Members

Namesort descending Modifiers Type Description Overrides
LingotekModerationFactory::$config protected property The collected moderation config services.
LingotekModerationFactory::$forms protected property The collected moderation form settings services.
LingotekModerationFactory::$handlers protected property The collected moderation handler services.
LingotekModerationFactory::addModerationConfiguration public function Called when the tag collector finds a moderation configuration service. Overrides LingotekModerationFactoryInterface::addModerationConfiguration
LingotekModerationFactory::addModerationForm public function Called when the tag collector finds a moderation settings form service. Overrides LingotekModerationFactoryInterface::addModerationForm
LingotekModerationFactory::addModerationHandler public function Called when the tag collector finds a moderation handler service. Overrides LingotekModerationFactoryInterface::addModerationHandler
LingotekModerationFactory::getModerationConfigurationService public function Gets the first moderation configuration service applying to a given entity. Overrides LingotekModerationFactoryInterface::getModerationConfigurationService
LingotekModerationFactory::getModerationHandler public function Gets the first moderation handler service that applies to the given entity. Overrides LingotekModerationFactoryInterface::getModerationHandler
LingotekModerationFactory::getModerationSettingsForm public function Gets the first moderation settings form service applying to a given entity. Overrides LingotekModerationFactoryInterface::getModerationSettingsForm
LingotekModerationFactory::__construct public function Constructs a \Drupal\lingotek\Moderation\LingotekModerationFactory object.