WorkspaceOperationFactory.php

Same filename and directory in other branches
  1. 9 core/modules/workspaces/src/WorkspaceOperationFactory.php
  2. 10 core/modules/workspaces/src/WorkspaceOperationFactory.php
  3. 11.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\Core\Cache\CacheTagsInvalidatorInterface;
use Drupal\Core\Database\Connection;
use Drupal\Core\Entity\EntityTypeManagerInterface;

/**
 * Defines a factory class for workspace operations.
 *
 * @see \Drupal\workspaces\WorkspaceOperationInterface
 * @see \Drupal\workspaces\WorkspacePublisherInterface
 *
 * @internal
 */
class WorkspaceOperationFactory {
    
    /**
     * 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;
    
    /**
     * The cache tags invalidator.
     *
     * @var \Drupal\Core\Cache\CacheTagsInvalidatorInterface
     */
    protected $cacheTagsInvalidator;
    
    /**
     * Constructs a new WorkspacePublisher.
     *
     * @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 \Drupal\Core\Cache\CacheTagsInvalidatorInterface $cache_tags_invalidator
     *   The cache tags invalidator service.
     */
    public function __construct(EntityTypeManagerInterface $entity_type_manager, Connection $database, WorkspaceManagerInterface $workspace_manager, WorkspaceAssociationInterface $workspace_association, CacheTagsInvalidatorInterface $cache_tags_invalidator) {
        $this->entityTypeManager = $entity_type_manager;
        $this->database = $database;
        $this->workspaceManager = $workspace_manager;
        $this->workspaceAssociation = $workspace_association;
        $this->cacheTagsInvalidator = $cache_tags_invalidator;
    }
    
    /**
     * 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, $source);
    }
    
    /**
     * 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, $this->cacheTagsInvalidator, $source, $target);
    }

}

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.