class WorkspaceOperationFactory

Same name and namespace in other branches
  1. 9 core/modules/workspaces/src/WorkspaceOperationFactory.php \Drupal\workspaces\WorkspaceOperationFactory
  2. 8.9.x core/modules/workspaces/src/WorkspaceOperationFactory.php \Drupal\workspaces\WorkspaceOperationFactory
  3. 11.x core/modules/workspaces/src/WorkspaceOperationFactory.php \Drupal\workspaces\WorkspaceOperationFactory

Defines a factory class for workspace operations.

@internal

Hierarchy

Expanded class hierarchy of WorkspaceOperationFactory

See also

\Drupal\workspaces\WorkspaceOperationInterface

\Drupal\workspaces\WorkspacePublisherInterface

3 files declare their use of WorkspaceOperationFactory
WorkspaceMergeForm.php in core/modules/workspaces/src/Form/WorkspaceMergeForm.php
WorkspacePublishForm.php in core/modules/workspaces/src/Form/WorkspacePublishForm.php
WorkspacePublishFormTest.php in core/modules/workspaces/tests/src/Kernel/WorkspacePublishFormTest.php
1 string reference to 'WorkspaceOperationFactory'
workspaces.services.yml in core/modules/workspaces/workspaces.services.yml
core/modules/workspaces/workspaces.services.yml
1 service uses WorkspaceOperationFactory
workspaces.operation_factory in core/modules/workspaces/workspaces.services.yml
Drupal\workspaces\WorkspaceOperationFactory

File

core/modules/workspaces/src/WorkspaceOperationFactory.php, line 20

Namespace

Drupal\workspaces
View source
class WorkspaceOperationFactory {
  use DeprecatedServicePropertyTrait;
  
  /**
   * Defines deprecated injected properties.
   *
   * @var array
   */
  protected array $deprecatedProperties = [
    'cacheTagInvalidator' => 'cache_tags.invalidator',
  ];
  
  /**
   * The entity type manager.
   *
   * @var \Drupal\Core\Entity\EntityTypeManagerInterface
   */
  protected $entityTypeManager;
  
  /**
   * The database connection.
   *
   * @var \Drupal\Core\Database\Connection
   */
  protected $database;
  
  /**
   * The workspace manager.
   *
   * @var \Drupal\workspaces\WorkspaceManagerInterface
   */
  protected $workspaceManager;
  
  /**
   * The workspace association service.
   *
   * @var \Drupal\workspaces\WorkspaceAssociationInterface
   */
  protected $workspaceAssociation;
  
  /**
   * An event dispatcher instance to use for configuration events.
   *
   * @var \Symfony\Contracts\EventDispatcher\EventDispatcherInterface
   */
  protected $eventDispatcher;
  
  /**
   * The logger service.
   *
   * @var \Psr\Log\LoggerInterface
   */
  protected $logger;
  
  /**
   * Constructs a new WorkspaceOperationFactory.
   *
   * @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager
   *   The entity type manager.
   * @param \Drupal\Core\Database\Connection $database
   *   Database connection.
   * @param \Drupal\workspaces\WorkspaceManagerInterface $workspace_manager
   *   The workspace manager service.
   * @param \Drupal\workspaces\WorkspaceAssociationInterface $workspace_association
   *   The workspace association service.
   * @param \Symfony\Contracts\EventDispatcher\EventDispatcherInterface|\Drupal\Core\Cache\CacheTagsInvalidatorInterface $event_dispatcher
   *   The event dispatcher.
   * @param \Psr\Log\LoggerInterface|null $logger
   *   The logger.
   */
  public function __construct(EntityTypeManagerInterface $entity_type_manager, Connection $database, WorkspaceManagerInterface $workspace_manager, WorkspaceAssociationInterface $workspace_association, EventDispatcherInterface|CacheTagsInvalidatorInterface $event_dispatcher, LoggerInterface|EventDispatcherInterface|null $logger = NULL) {
    $this->entityTypeManager = $entity_type_manager;
    $this->database = $database;
    $this->workspaceManager = $workspace_manager;
    $this->workspaceAssociation = $workspace_association;
    if ($event_dispatcher instanceof CacheTagsInvalidatorInterface) {
      $event_dispatcher = \Drupal::service('event_dispatcher');
      @trigger_error('Calling ' . __METHOD__ . '() with the $cache_tags_invalidator argument is deprecated in drupal:10.3.0 and is removed from drupal:11.0.0. See https://www.drupal.org/node/3440755', E_USER_DEPRECATED);
    }
    elseif (!$event_dispatcher instanceof EventDispatcherInterface) {
      $event_dispatcher = \Drupal::service('event_dispatcher');
      @trigger_error('Calling ' . __METHOD__ . '() without the $event_dispatcher argument is deprecated in drupal:10.1.0 and it will be required in drupal:11.0.0. See https://www.drupal.org/node/3242573', E_USER_DEPRECATED);
    }
    $this->eventDispatcher = $event_dispatcher;
    $logger = func_get_arg(5);
    if (!$logger instanceof LoggerInterface) {
      $logger = \Drupal::service('logger.channel.workspaces');
      @trigger_error('Calling ' . __METHOD__ . '() without the $logger argument is deprecated in drupal:10.1.0 and it will be required in drupal:11.0.0. See https://www.drupal.org/node/2932520', E_USER_DEPRECATED);
    }
    $this->logger = $logger;
  }
  
  /**
   * Gets the workspace publisher.
   *
   * @param \Drupal\workspaces\WorkspaceInterface $source
   *   A workspace entity.
   *
   * @return \Drupal\workspaces\WorkspacePublisherInterface
   *   A workspace publisher object.
   */
  public function getPublisher(WorkspaceInterface $source) {
    return new WorkspacePublisher($this->entityTypeManager, $this->database, $this->workspaceManager, $this->workspaceAssociation, $this->eventDispatcher, $source, $this->logger);
  }
  
  /**
   * Gets the workspace merger.
   *
   * @param \Drupal\workspaces\WorkspaceInterface $source
   *   The source workspace entity.
   * @param \Drupal\workspaces\WorkspaceInterface $target
   *   The target workspace entity.
   *
   * @return \Drupal\workspaces\WorkspaceMergerInterface
   *   A workspace merger object.
   */
  public function getMerger(WorkspaceInterface $source, WorkspaceInterface $target) {
    return new WorkspaceMerger($this->entityTypeManager, $this->database, $this->workspaceAssociation, $source, $target, $this->logger);
  }

}

Members

Title Sort descending Modifiers Object type Summary
DeprecatedServicePropertyTrait::__get public function Allows to access deprecated/removed properties.
WorkspaceOperationFactory::$database protected property The database connection.
WorkspaceOperationFactory::$deprecatedProperties protected property Defines deprecated injected properties.
WorkspaceOperationFactory::$entityTypeManager protected property The entity type manager.
WorkspaceOperationFactory::$eventDispatcher protected property An event dispatcher instance to use for configuration events.
WorkspaceOperationFactory::$logger protected property The logger service.
WorkspaceOperationFactory::$workspaceAssociation protected property The workspace association service.
WorkspaceOperationFactory::$workspaceManager protected property The workspace manager.
WorkspaceOperationFactory::getMerger public function Gets the workspace merger.
WorkspaceOperationFactory::getPublisher public function Gets the workspace publisher.
WorkspaceOperationFactory::__construct public function Constructs a new WorkspaceOperationFactory.

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.