WorkspaceOperationFactory.php

Same filename and directory in other branches
  1. 11.x core/modules/workspaces/src/WorkspaceOperationFactory.php
  2. 10 core/modules/workspaces/src/WorkspaceOperationFactory.php
  3. 9 core/modules/workspaces/src/WorkspaceOperationFactory.php
  4. 8.9.x core/modules/workspaces/src/WorkspaceOperationFactory.php

Namespace

Drupal\workspaces

File

core/modules/workspaces/src/WorkspaceOperationFactory.php

View source
<?php

namespace Drupal\workspaces;

use Drupal\Component\Datetime\TimeInterface;
use Drupal\Core\Database\Connection;
use Drupal\Core\Entity\EntityTypeManagerInterface;
use Psr\Log\LoggerInterface;
use Symfony\Component\DependencyInjection\Attribute\Autowire;
use Symfony\Contracts\EventDispatcher\EventDispatcherInterface;

/**
 * Defines a factory class for workspace operations.
 *
 * @see \Drupal\workspaces\WorkspaceOperationInterface
 * @see \Drupal\workspaces\WorkspacePublisherInterface
 *
 * @internal
 */
class WorkspaceOperationFactory {
  public function __construct(protected EntityTypeManagerInterface $entityTypeManager, protected Connection $database, protected WorkspaceManagerInterface $workspaceManager, protected WorkspaceTrackerInterface $workspaceTracker, protected EventDispatcherInterface $eventDispatcher, #[Autowire(service: 'logger.channel.workspaces')] protected LoggerInterface $logger, protected TimeInterface $time) {
  }
  
  /**
   * 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->workspaceTracker, $this->eventDispatcher, $source, $this->logger, $this->time);
  }
  
  /**
   * 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->workspaceTracker, $source, $target, $this->logger);
  }

}

Classes

Title Deprecated Summary
WorkspaceOperationFactory Defines a factory class for workspace operations.

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