EntityVisibilityForm.php in Open Social 8
Same filename and directory in other branches
- 8.9 modules/custom/entity_access_by_field/src/Form/EntityVisibilityForm.php
- 8.2 modules/custom/entity_access_by_field/src/Form/EntityVisibilityForm.php
- 8.3 modules/custom/entity_access_by_field/src/Form/EntityVisibilityForm.php
- 8.4 modules/custom/entity_access_by_field/src/Form/EntityVisibilityForm.php
- 8.5 modules/custom/entity_access_by_field/src/Form/EntityVisibilityForm.php
- 8.6 modules/custom/entity_access_by_field/src/Form/EntityVisibilityForm.php
- 8.7 modules/custom/entity_access_by_field/src/Form/EntityVisibilityForm.php
- 8.8 modules/custom/entity_access_by_field/src/Form/EntityVisibilityForm.php
- 10.3.x modules/custom/entity_access_by_field/src/Form/EntityVisibilityForm.php
- 10.0.x modules/custom/entity_access_by_field/src/Form/EntityVisibilityForm.php
- 10.1.x modules/custom/entity_access_by_field/src/Form/EntityVisibilityForm.php
- 10.2.x modules/custom/entity_access_by_field/src/Form/EntityVisibilityForm.php
Namespace
Drupal\entity_access_by_field\FormFile
modules/custom/entity_access_by_field/src/Form/EntityVisibilityForm.phpView source
<?php
namespace Drupal\entity_access_by_field\Form;
use Drupal\Core\Form\ConfigFormBase;
use Drupal\Core\Form\FormStateInterface;
/**
* Class EntityVisibilityForm.
*
* @package Drupal\entity_access_by_field\Form
*/
class EntityVisibilityForm extends ConfigFormBase {
/**
* {@inheritdoc}
*/
protected function getEditableConfigNames() {
return [
'entity_access_by_field.settings',
];
}
/**
* {@inheritdoc}
*/
public function getFormId() {
return 'entity_access_by_field_visibility_form';
}
/**
* {@inheritdoc}
*/
public function buildForm(array $form, FormStateInterface $form_state) {
// Get config for this form.
$config = $this
->config('entity_access_by_field.settings');
$form['disable_public_visibility'] = [
'#type' => 'checkbox',
'#title' => $this
->t('Disable public visibility'),
'#description' => $this
->t('Turning on this feature makes sure regular user can no longer post public content anywhere on the platform.'),
'#default_value' => $config
->get('disable_public_visibility'),
];
$form['default_visibility'] = [
'#type' => 'select',
'#title' => $this
->t('Default visibility'),
'#default_value' => $config
->get('default_visibility'),
'#options' => [
'public' => $this
->t('Public - visible to everyone including people who are not a member'),
'community' => $this
->t('Community - visible only to logged in members'),
],
];
return parent::buildForm($form, $form_state);
}
/**
* {@inheritdoc}
*/
public function submitForm(array &$form, FormStateInterface $form_state) {
$form_state
->cleanValues();
$this
->config('entity_access_by_field.settings')
->setData($form_state
->getValues())
->save();
parent::submitForm($form, $form_state);
}
}
Classes
Name | Description |
---|---|
EntityVisibilityForm | Class EntityVisibilityForm. |