diff -u b/modal_page.install b/modal_page.install --- b/modal_page.install +++ b/modal_page.install @@ -11,7 +11,6 @@ use Drupal\modal_page\Helper\ModalPageFieldHelper; use Drupal\modal_page\Entity\Modal; - /** * Created new field to choose label "Don't show again". */ @@ -19,6 +18,12 @@ $modalPageFieldHelper = new ModalPageFieldHelper(); $fieldDontShowAgainLabel = $modalPageFieldHelper->getFieldDontShowAgainLabel(); \Drupal::entityDefinitionUpdateManager()->installFieldStorageDefinition('dont_show_again_label', 'modal_page_modal', 'modal_page_modal', $fieldDontShowAgainLabel); + + $field_to_be_updated = ['dont_show_again_label' => t("Don't show again")]; + + modal_page_update_modal_table($field_to_be_updated); + + \Drupal::service('cache.render')->invalidateAll(); } /** diff -u b/src/Helper/ModalPageFieldHelper.php b/src/Helper/ModalPageFieldHelper.php --- b/src/Helper/ModalPageFieldHelper.php +++ b/src/Helper/ModalPageFieldHelper.php @@ -3,21 +3,22 @@ namespace Drupal\modal_page\Helper; use Drupal\Core\Field\BaseFieldDefinition; +use Drupal\Core\StringTranslation\StringTranslationTrait; /** * Modal Page Field Helper. */ class ModalPageFieldHelper { + use StringTranslationTrait; + /** * Get Field Role. */ public function getFieldRole() { - // @codingStandardsIgnoreStart - $label = t('Who can access this Modal'); - $description = t('If no role is selected this Modal will be visible to everyone.'); - // @codingStandardsIgnoreEnd + $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); @@ -37,28 +38,27 @@ /** * Get "Don't show again label". */ - public function getFieldDontShowAgainLabel() - { + public function getFieldDontShowAgainLabel() { - $dontShowAgainLabel = BaseFieldDefinition::create('string') - ->setLabel(t("Label")) - ->setDefaultValue(t("Don't show again")) - ->setDescription(t("If blank the value will be Don't show again")) - ->setSettings([ + $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 Don't show again")); + $dontShowAgainLabel->setDisplayConfigurable('form', TRUE); + $dontShowAgainLabel->setDisplayConfigurable('view', TRUE); + $dontShowAgainLabel->setSettings([ 'max_length' => 255, 'text_processing' => 0, - ]) - ->setDisplayOptions('view', [ - 'label' => 'above', - 'type' => 'string', - 'weight' => -5, - ]) - ->setDisplayOptions('form', [ - 'type' => 'string_textfield', - 'weight' => -5, - ]) - ->setDisplayConfigurable('form', TRUE) - ->setDisplayConfigurable('view', TRUE); + ]); + $dontShowAgainLabel->setDisplayOptions('form', [ + 'type' => 'string_textfield', + 'weight' => -5, + ]); + $dontShowAgainLabel->setDisplayOptions('view', [ + 'label' => 'above', + 'type' => 'string', + 'weight' => -5, + ]); return $dontShowAgainLabel; }