QueryParameterWorkspaceNegotiator.php

Same filename in other branches
  1. 9 core/modules/workspaces/src/Negotiator/QueryParameterWorkspaceNegotiator.php
  2. 10 core/modules/workspaces/src/Negotiator/QueryParameterWorkspaceNegotiator.php
  3. 11.x core/modules/workspaces/src/Negotiator/QueryParameterWorkspaceNegotiator.php

Namespace

Drupal\workspaces\Negotiator

File

core/modules/workspaces/src/Negotiator/QueryParameterWorkspaceNegotiator.php

View source
<?php

namespace Drupal\workspaces\Negotiator;

use Symfony\Component\HttpFoundation\Request;

/**
 * Defines the query parameter workspace negotiator.
 */
class QueryParameterWorkspaceNegotiator extends SessionWorkspaceNegotiator {
    
    /**
     * {@inheritdoc}
     */
    public function applies(Request $request) {
        return is_string($request->query
            ->get('workspace')) && parent::applies($request);
    }
    
    /**
     * {@inheritdoc}
     */
    public function getActiveWorkspace(Request $request) {
        $workspace_id = $request->query
            ->get('workspace');
        if ($workspace_id && ($workspace = $this->workspaceStorage
            ->load($workspace_id))) {
            $this->setActiveWorkspace($workspace);
            return $workspace;
        }
        return NULL;
    }

}

Classes

Title Deprecated Summary
QueryParameterWorkspaceNegotiator Defines the query parameter workspace negotiator.

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