Further Drupal 8.6.4 changes. Some core files were not committed before a commit...
[yaffs-website] / web / core / modules / workspaces / src / WorkspaceOperationFactory.php
1 <?php
2
3 namespace Drupal\workspaces;
4
5 use Drupal\Core\Database\Connection;
6 use Drupal\Core\Entity\EntityTypeManagerInterface;
7
8 /**
9  * Defines a factory class for workspace operations.
10  *
11  * @see \Drupal\workspaces\WorkspaceOperationInterface
12  * @see \Drupal\workspaces\WorkspacePublisherInterface
13  *
14  * @internal
15  */
16 class WorkspaceOperationFactory {
17
18   /**
19    * The entity type manager.
20    *
21    * @var \Drupal\Core\Entity\EntityTypeManagerInterface
22    */
23   protected $entityTypeManager;
24
25   /**
26    * The database connection.
27    *
28    * @var \Drupal\Core\Database\Connection
29    */
30   protected $database;
31
32   /**
33    * Constructs a new WorkspacePublisher.
34    *
35    * @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager
36    *   The entity type manager.
37    * @param \Drupal\Core\Database\Connection $database
38    *   Database connection.
39    */
40   public function __construct(EntityTypeManagerInterface $entity_type_manager, Connection $database) {
41     $this->entityTypeManager = $entity_type_manager;
42     $this->database = $database;
43   }
44
45   /**
46    * Gets the workspace publisher.
47    *
48    * @param \Drupal\workspaces\WorkspaceInterface $source
49    *   A workspace entity.
50    *
51    * @return \Drupal\workspaces\WorkspacePublisherInterface
52    *   A workspace publisher object.
53    */
54   public function getPublisher(WorkspaceInterface $source) {
55     return new WorkspacePublisher($this->entityTypeManager, $this->database, $source);
56   }
57
58 }