WorkflowAccessSettingsForm.php in Workflow 8
File
modules/workflow_access/src/Form/WorkflowAccessSettingsForm.php
View source
<?php
namespace Drupal\workflow_access\Form;
use Drupal\Core\Form\ConfigFormBase;
use Drupal\Core\Form\FormStateInterface;
class WorkflowAccessSettingsForm extends ConfigFormBase {
public function getFormId() {
return 'workflow_access_settings';
}
protected function getEditableConfigNames() {
return [
'workflow_access.settings',
];
}
public function buildForm(array $form, FormStateInterface $form_state) {
$config = $this
->config('workflow_access.settings');
$weight = $config
->get('workflow_access_priority');
$form['workflow_access'] = [
'#type' => 'details',
'#open' => TRUE,
'#title' => $this
->t('Workflow Access Settings'),
];
$form['workflow_access']['#tree'] = TRUE;
$url = 'https://api.drupal.org/api/drupal/core%21modules%21node%21node.api.php/function/hook_node_access_records/8';
$form['workflow_access']['workflow_access_priority'] = [
'#type' => 'weight',
'#delta' => 10,
'#title' => $this
->t('Workflow Access Priority'),
'#default_value' => $weight,
'#description' => $this
->t('This sets the node access priority. Changing this setting can be
dangerous. If there is any doubt, leave it at 0.
<a href=":url" target="_blank">Read the manual</a>.', [
':url' => $url,
]),
];
return parent::buildForm($form, $form_state);
}
public function validateForm(array &$form, FormStateInterface $form_state) {
}
public function submitForm(array &$form, FormStateInterface $form_state) {
$weight = $form_state
->getValues()['workflow_access']['workflow_access_priority'];
$this
->config('workflow_access.settings')
->set('workflow_access_priority', $weight)
->save();
parent::submitForm($form, $form_state);
}
}