Updated Drupal to 8.6. This goes with the following updates because it's possible...
[yaffs-website] / web / core / modules / workspaces / src / WorkspaceOperationFactory.php
diff --git a/web/core/modules/workspaces/src/WorkspaceOperationFactory.php b/web/core/modules/workspaces/src/WorkspaceOperationFactory.php
new file mode 100644 (file)
index 0000000..bc93d87
--- /dev/null
@@ -0,0 +1,58 @@
+<?php
+
+namespace Drupal\workspaces;
+
+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;
+
+  /**
+   * Constructs a new WorkspacePublisher.
+   *
+   * @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager
+   *   The entity type manager.
+   * @param \Drupal\Core\Database\Connection $database
+   *   Database connection.
+   */
+  public function __construct(EntityTypeManagerInterface $entity_type_manager, Connection $database) {
+    $this->entityTypeManager = $entity_type_manager;
+    $this->database = $database;
+  }
+
+  /**
+   * 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, $source);
+  }
+
+}