class ModalPageFieldHelper in Modal 8.3
Same name and namespace in other branches
- 8.2 src/Helper/ModalPageFieldHelper.php \Drupal\modal_page\Helper\ModalPageFieldHelper
Modal Page Field Helper.
Hierarchy
- class \Drupal\modal_page\Helper\ModalPageFieldHelper uses StringTranslationTrait
Expanded class hierarchy of ModalPageFieldHelper
2 files declare their use of ModalPageFieldHelper
- Modal.php in src/
Entity/ Modal.php - modal_page.install in ./
modal_page.install - Install, update and uninstall functions for the Modal Page.
File
- src/
Helper/ ModalPageFieldHelper.php, line 11
Namespace
Drupal\modal_page\HelperView source
class ModalPageFieldHelper {
use StringTranslationTrait;
/**
* Get Field Role.
*/
public function getFieldRole() {
$label = $this
->t('Who can access this Modal');
$description = $this
->t('If no role is selected this Modal will be visible to everyone.');
$fieldRoles = BaseFieldDefinition::create('list_string');
$fieldRoles
->setLabel($label);
$fieldRoles
->setSettings([
'allowed_values' => user_role_names(),
]);
$fieldRoles
->setDescription($description);
$fieldRoles
->setRequired(FALSE);
$fieldRoles
->setCardinality(-1);
$fieldRoles
->setDisplayOptions('form', [
'type' => 'options_buttons',
'weight' => 6,
]);
$fieldRoles
->setDisplayConfigurable('form', TRUE);
return $fieldRoles;
}
/**
* Get "Don't show again label".
*/
public function getFieldDontShowAgainLabel() {
$dontShowAgainLabel = BaseFieldDefinition::create('string');
$dontShowAgainLabel
->setLabel($this
->t("Label"));
$dontShowAgainLabel
->setDefaultValue($this
->t("Don't show again"));
$dontShowAgainLabel
->setDescription($this
->t("If blank the value will be <b>Don't show again</b>"));
$dontShowAgainLabel
->setDisplayConfigurable('form', TRUE);
$dontShowAgainLabel
->setDisplayConfigurable('view', TRUE);
$dontShowAgainLabel
->setSettings([
'max_length' => 255,
'text_processing' => 0,
]);
$dontShowAgainLabel
->setDisplayOptions('form', [
'type' => 'string_textfield',
'weight' => -5,
]);
$dontShowAgainLabel
->setDisplayOptions('view', [
'label' => 'above',
'type' => 'string',
'weight' => -5,
]);
return $dontShowAgainLabel;
}
/**
* Get Field "Close Modal ESC Key".
*/
public function getFieldCloseModalEscKey() {
$closeModalEscKey = BaseFieldDefinition::create('boolean');
$closeModalEscKey
->setLabel($this
->t("Close Modal pressing ESC key"));
$closeModalEscKey
->setDefaultValue(TRUE);
$closeModalEscKey
->setDescription($this
->t("If unchecked, the end-user will not be able to close the modal clicking the ESC key"));
$closeModalEscKey
->setDisplayConfigurable('form', TRUE);
$closeModalEscKey
->setDisplayOptions('form', [
'type' => 'boolean_checkbox',
'settings' => [
'display_label' => TRUE,
],
'weight' => -5,
]);
return $closeModalEscKey;
}
/**
* Get Field "Close Modal Clicking Outside".
*/
public function getFieldCloseClickingOutside() {
$closeModalClickingOutside = BaseFieldDefinition::create('boolean');
$closeModalClickingOutside
->setLabel($this
->t("Close Modal clicking outside the modal"));
$closeModalClickingOutside
->setDefaultValue(TRUE);
$closeModalClickingOutside
->setDescription($this
->t("If unchecked, the end-user will not be able to close the modal clicking outside the modal"));
$closeModalClickingOutside
->setDisplayConfigurable('form', TRUE);
$closeModalClickingOutside
->setDisplayOptions('form', [
'type' => 'boolean_checkbox',
'settings' => [
'display_label' => TRUE,
],
'weight' => -5,
]);
return $closeModalClickingOutside;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
ModalPageFieldHelper:: |
public | function | Get Field "Close Modal Clicking Outside". | |
ModalPageFieldHelper:: |
public | function | Get Field "Close Modal ESC Key". | |
ModalPageFieldHelper:: |
public | function | Get "Don't show again label". | |
ModalPageFieldHelper:: |
public | function | Get Field Role. | |
StringTranslationTrait:: |
protected | property | The string translation service. | 1 |
StringTranslationTrait:: |
protected | function | Formats a string containing a count of items. | |
StringTranslationTrait:: |
protected | function | Returns the number of plurals supported by a given language. | |
StringTranslationTrait:: |
protected | function | Gets the string translation service. | |
StringTranslationTrait:: |
public | function | Sets the string translation service to use. | 2 |
StringTranslationTrait:: |
protected | function | Translates a string to the current language or to a given language. |