class FormOperations implements ContainerInjectionInterface (View source)

internal  
 

Defines a class for reacting to form operations.

Properties

protected WorkspaceManagerInterface $workspaceManager

The workspace manager service.

Methods

__construct(WorkspaceManagerInterface $workspace_manager)

Constructs a new FormOperations instance.

static 
create(ContainerInterface $container)

Instantiates a new instance of this class.

formAlter(array $form, FormStateInterface $form_state, string $form_id)

Alters forms to disallow editing in non-default workspaces.

addWorkspaceValidation(array $element)

Adds our validation handler recursively on each element of a form.

static 
validateDefaultWorkspace(array $form, FormStateInterface $form_state)

Validation handler which sets a validation error for all unsupported forms.

Details

__construct(WorkspaceManagerInterface $workspace_manager)

Constructs a new FormOperations instance.

Parameters

WorkspaceManagerInterface $workspace_manager

The workspace manager service.

static create(ContainerInterface $container)

Instantiates a new instance of this class.

This is a factory method that returns a new instance of this class. The factory should pass any needed dependencies into the constructor of this class, but not the container itself. Every call to this method must return a new instance of this class; that is, it may not implement a singleton.

Parameters

ContainerInterface $container

The service container this instance should use.

formAlter(array $form, FormStateInterface $form_state, string $form_id)

Alters forms to disallow editing in non-default workspaces.

Parameters

array $form

An associative array containing the structure of the form.

FormStateInterface $form_state

The current state of the form.

string $form_id

The form ID.

See also

hook_form_alter()

protected addWorkspaceValidation(array $element)

Adds our validation handler recursively on each element of a form.

Parameters

array $element

An associative array containing the structure of the form.

static validateDefaultWorkspace(array $form, FormStateInterface $form_state)

Validation handler which sets a validation error for all unsupported forms.

Parameters

array $form
FormStateInterface $form_state