WorkspaceOperationFactory.php 1.4 KB

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