You are here

protected function ReplicationForm::getDefaultSource in Deploy - Content Staging 8

Returns a source object.

2 calls to ReplicationForm::getDefaultSource()
ReplicationForm::addTitle in src/Entity/Form/ReplicationForm.php
Format the title of the Replication process.
ReplicationForm::buildForm in src/Entity/Form/ReplicationForm.php
Form constructor.

File

src/Entity/Form/ReplicationForm.php, line 229

Class

ReplicationForm
Form controller for Replication edit forms.

Namespace

Drupal\deploy\Entity\Form

Code

protected function getDefaultSource() {
  if (!empty($this->source)) {
    return $this->source;
  }
  if (!empty($this->entity
    ->get('source')) && $this->entity
    ->get('source')->entity instanceof WorkspacePointerInterface) {
    return $this->source = $this->entity
      ->get('source')->entity;
  }

  /* @var \Drupal\multiversion\Entity\Workspace $workspace */
  $workspace = \Drupal::service('workspace.manager')
    ->getActiveWorkspace();
  $workspace_pointers = \Drupal::service('entity_type.manager')
    ->getStorage('workspace_pointer')
    ->loadByProperties([
    'workspace_pointer' => $workspace
      ->id(),
  ]);
  return $this->source = reset($workspace_pointers);
}