TestWorkspaceNegotiator.php

Same filename and directory in other branches
  1. 9 core/modules/workspaces/tests/modules/workspace_update_test/src/Negotiator/TestWorkspaceNegotiator.php
  2. 8.9.x core/modules/workspaces/tests/modules/workspace_update_test/src/Negotiator/TestWorkspaceNegotiator.php
  3. 11.x core/modules/workspaces/tests/modules/workspace_update_test/src/Negotiator/TestWorkspaceNegotiator.php

Namespace

Drupal\workspace_update_test\Negotiator

File

core/modules/workspaces/tests/modules/workspace_update_test/src/Negotiator/TestWorkspaceNegotiator.php

View source
<?php

namespace Drupal\workspace_update_test\Negotiator;

use Drupal\workspaces\Entity\Workspace;
use Drupal\workspaces\Negotiator\WorkspaceIdNegotiatorInterface;
use Drupal\workspaces\Negotiator\WorkspaceNegotiatorInterface;
use Drupal\workspaces\WorkspaceInterface;
use Symfony\Component\HttpFoundation\Request;

/**
 * Defines a workspace negotiator used for testing.
 */
class TestWorkspaceNegotiator implements WorkspaceNegotiatorInterface, WorkspaceIdNegotiatorInterface {
  
  /**
   * {@inheritdoc}
   */
  public function applies(Request $request) {
    return TRUE;
  }
  
  /**
   * {@inheritdoc}
   */
  public function getActiveWorkspaceId(Request $request) : ?string {
    return 'test';
  }
  
  /**
   * {@inheritdoc}
   */
  public function getActiveWorkspace(Request $request) {
    return Workspace::load($this->getActiveWorkspaceId($request));
  }
  
  /**
   * {@inheritdoc}
   */
  public function setActiveWorkspace(WorkspaceInterface $workspace) {
    // Nothing to do here.
  }
  
  /**
   * {@inheritdoc}
   */
  public function unsetActiveWorkspace() {
    // Nothing to do here.
  }

}

Classes

Title Deprecated Summary
TestWorkspaceNegotiator Defines a workspace negotiator used for testing.

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.