You are here

class EntityOperations in Workspace 8

Same name and namespace in other branches
  1. 8.2 src/EntityOperations.php \Drupal\workspace\EntityOperations

Defines a class for reacting to entity events.

Hierarchy

Expanded class hierarchy of EntityOperations

1 string reference to 'EntityOperations'
workspace.services.yml in ./workspace.services.yml
workspace.services.yml
1 service uses EntityOperations
workspace.entity_operations in ./workspace.services.yml
Drupal\workspace\EntityOperations

File

src/EntityOperations.php, line 15

Namespace

Drupal\workspace
View source
class EntityOperations {

  /**
   * @var \Drupal\multiversion\MultiversionManagerInterface
   */
  protected $multiversionManager;

  /**
   * @var \Drupal\Core\Entity\EntityTypeManagerInterface
   */
  protected $entityTypeManager;

  /**
   * Constructs a new Toolbar.
   *
   * @param \Drupal\multiversion\MultiversionManagerInterface $multiversion_manager
   * @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager
   * @param \Drupal\Core\Queue\QueueInterface $queue
   */
  public function __construct(MultiversionManagerInterface $multiversion_manager, EntityTypeManagerInterface $entity_type_manager, QueueFactory $queue) {
    $this->multiversionManager = $multiversion_manager;
    $this->entityTypeManager = $entity_type_manager;
    $this->queue = $queue;
  }

  /**
   * Hook bridge for hook_workspace_insert()
   *
   * @see hook_ENTITY_TYPE_insert()
   *
   * @param \Drupal\multiversion\Entity\WorkspaceInterface $workspace
   *   The workspace entity that is being created.
   */
  public function workspaceInsert(WorkspaceInterface $workspace) {

    // Create a new pointer to every Workspace that gets created.
    // This is mainly so that we can always backtrack from a Workspace to a
    // pointer to provide a consistent API to replicators.
    $pointer = $this->entityTypeManager
      ->getStorage('workspace_pointer')
      ->create();
    $pointer
      ->setWorkspace($workspace);
    $pointer
      ->save();
  }

}

Members

Namesort descending Modifiers Type Description Overrides
EntityOperations::$entityTypeManager protected property
EntityOperations::$multiversionManager protected property
EntityOperations::workspaceInsert public function Hook bridge for hook_workspace_insert()
EntityOperations::__construct public function Constructs a new Toolbar.