Loading src/Form/BlockClassSettingsForm.php +12 −12 Changes for src/Form/BlockClassSettingsForm.php: 12 added lines, 12 removed lines. Original line number Diff line number Diff line Loading @@ -133,20 +133,20 @@ class BlockClassSettingsForm extends ConfigFormBase { '#default_value' => $field_type, ]; $field_type_custom_attributes = 'textfield'; $field_type_attributes = 'textarea'; if (!empty($config->get('field_type'))) { $field_type_custom_attributes = $config->get('field_type_custom_attributes'); $field_type_attributes = $config->get('field_type_attributes'); } $form['global_settings']['field_type_custom_attributes'] = [ '#title' => $this->t("Field Type for Custom Attributes"), $form['global_settings']['field_type_attributes'] = [ '#title' => $this->t("Field Type for Attributes"), '#type' => 'select', '#options' => [ 'textfield' => $this->t('textfield'), 'textarea' => $this->t('textarea'), ], '#default_value' => $field_type_custom_attributes, '#default_value' => $field_type_attributes, ]; $maxlength_block_class_field = 255; Loading @@ -169,10 +169,10 @@ class BlockClassSettingsForm extends ConfigFormBase { '#default_value' => $config->get('allow_only_letters_and_numbers'), ]; $form['global_settings']['enable_custom_attributes'] = [ '#title' => $this->t("Enable custom attributes"), $form['global_settings']['enable_attributes'] = [ '#title' => $this->t("Enable attributes"), '#type' => 'checkbox', '#default_value' => $config->get('enable_custom_attributes'), '#default_value' => $config->get('enable_attributes'), ]; $form['actions'] = [ Loading Loading @@ -215,14 +215,14 @@ class BlockClassSettingsForm extends ConfigFormBase { // Get the field type. $field_type = $form_state->getValue('field_type'); $field_type_custom_attributes = $form_state->getValue('field_type_custom_attributes'); $field_type_attributes = $form_state->getValue('field_type_attributes'); // Get the maxlength_block_class_field field. $maxlength_block_class_field = $form_state->getValue('maxlength_block_class_field'); $allow_only_letters_and_numbers = $form_state->getValue('allow_only_letters_and_numbers'); $enable_custom_attributes = $form_state->getValue('enable_custom_attributes'); $enable_attributes = $form_state->getValue('enable_attributes'); // Get the config object. $config = $this->config('block_class.settings'); Loading Loading @@ -254,10 +254,10 @@ class BlockClassSettingsForm extends ConfigFormBase { // Set the values. $config->set('default_case', $default_case); $config->set('field_type', $field_type); $config->set('field_type_custom_attributes', $field_type_custom_attributes); $config->set('field_type_attributes', $field_type_attributes); $config->set('maxlength_block_class_field', $maxlength_block_class_field); $config->set('allow_only_letters_and_numbers', $allow_only_letters_and_numbers); $config->set('enable_custom_attributes', $enable_custom_attributes); $config->set('enable_attributes', $enable_attributes); // Save that. $config->save(); Loading src/Service/BlockClassHelperService.php +20 −11 Changes for src/Service/BlockClassHelperService.php: 20 added lines, 11 removed lines. Original line number Diff line number Diff line Loading @@ -133,9 +133,9 @@ class BlockClassHelperService { $entity->unsetThirdPartySetting('block_class', 'classes'); } // If there is no custom attributes, unset the Third Party Setting. if (empty($entity->getThirdPartySetting('block_class', 'custom_attributes'))) { $entity->unsetThirdPartySetting('block_class', 'custom_attributes'); // If there is no attributes, unset the Third Party Setting. if (empty($entity->getThirdPartySetting('block_class', 'attributes'))) { $entity->unsetThirdPartySetting('block_class', 'attributes'); } // Get the config object. Loading Loading @@ -245,9 +245,9 @@ class BlockClassHelperService { // Load the block by ID. $block = Block::load($variables['elements']['#id']); if (!empty($block->getThirdPartySetting('block_class', 'custom_attributes'))) { if (!empty($block->getThirdPartySetting('block_class', 'attributes'))) { $attributes = $block->getThirdPartySetting('block_class', 'custom_attributes'); $attributes = $block->getThirdPartySetting('block_class', 'attributes'); $attributes = explode('|', $attributes); Loading Loading @@ -323,12 +323,21 @@ class BlockClassHelperService { '#maxlength' => $maxlength_block_class_field, ]; if (!empty($config->get('enable_custom_attributes'))) { $form['third_party_settings']['block_class']['custom_attributes'] = [ '#type' => 'textfield', '#title' => $this->t('Custom Attributes'), '#description' => $this->t('Here you can insert any attributes, for example: data-attribute-invite=new-data'), '#default_value' => $block->getThirdPartySetting('block_class', 'custom_attributes'), if (!empty($config->get('enable_attributes'))) { // Default field type. $field_type_attributes = 'textarea'; // Get the field type if exists. if (!empty($config->get('field_type_attributes'))) { $field_type_attributes = $config->get('field_type_attributes'); } $form['third_party_settings']['block_class']['attributes'] = [ '#type' => $field_type_attributes, '#title' => $this->t('Attributes'), '#description' => $this->t('Here you can insert any attributes, use one per line. For example: data-block-type|info'), '#default_value' => $block->getThirdPartySetting('block_class', 'attributes'), '#maxlength' => 255, ]; } Loading Loading
src/Form/BlockClassSettingsForm.php +12 −12 Changes for src/Form/BlockClassSettingsForm.php: 12 added lines, 12 removed lines. Original line number Diff line number Diff line Loading @@ -133,20 +133,20 @@ class BlockClassSettingsForm extends ConfigFormBase { '#default_value' => $field_type, ]; $field_type_custom_attributes = 'textfield'; $field_type_attributes = 'textarea'; if (!empty($config->get('field_type'))) { $field_type_custom_attributes = $config->get('field_type_custom_attributes'); $field_type_attributes = $config->get('field_type_attributes'); } $form['global_settings']['field_type_custom_attributes'] = [ '#title' => $this->t("Field Type for Custom Attributes"), $form['global_settings']['field_type_attributes'] = [ '#title' => $this->t("Field Type for Attributes"), '#type' => 'select', '#options' => [ 'textfield' => $this->t('textfield'), 'textarea' => $this->t('textarea'), ], '#default_value' => $field_type_custom_attributes, '#default_value' => $field_type_attributes, ]; $maxlength_block_class_field = 255; Loading @@ -169,10 +169,10 @@ class BlockClassSettingsForm extends ConfigFormBase { '#default_value' => $config->get('allow_only_letters_and_numbers'), ]; $form['global_settings']['enable_custom_attributes'] = [ '#title' => $this->t("Enable custom attributes"), $form['global_settings']['enable_attributes'] = [ '#title' => $this->t("Enable attributes"), '#type' => 'checkbox', '#default_value' => $config->get('enable_custom_attributes'), '#default_value' => $config->get('enable_attributes'), ]; $form['actions'] = [ Loading Loading @@ -215,14 +215,14 @@ class BlockClassSettingsForm extends ConfigFormBase { // Get the field type. $field_type = $form_state->getValue('field_type'); $field_type_custom_attributes = $form_state->getValue('field_type_custom_attributes'); $field_type_attributes = $form_state->getValue('field_type_attributes'); // Get the maxlength_block_class_field field. $maxlength_block_class_field = $form_state->getValue('maxlength_block_class_field'); $allow_only_letters_and_numbers = $form_state->getValue('allow_only_letters_and_numbers'); $enable_custom_attributes = $form_state->getValue('enable_custom_attributes'); $enable_attributes = $form_state->getValue('enable_attributes'); // Get the config object. $config = $this->config('block_class.settings'); Loading Loading @@ -254,10 +254,10 @@ class BlockClassSettingsForm extends ConfigFormBase { // Set the values. $config->set('default_case', $default_case); $config->set('field_type', $field_type); $config->set('field_type_custom_attributes', $field_type_custom_attributes); $config->set('field_type_attributes', $field_type_attributes); $config->set('maxlength_block_class_field', $maxlength_block_class_field); $config->set('allow_only_letters_and_numbers', $allow_only_letters_and_numbers); $config->set('enable_custom_attributes', $enable_custom_attributes); $config->set('enable_attributes', $enable_attributes); // Save that. $config->save(); Loading
src/Service/BlockClassHelperService.php +20 −11 Changes for src/Service/BlockClassHelperService.php: 20 added lines, 11 removed lines. Original line number Diff line number Diff line Loading @@ -133,9 +133,9 @@ class BlockClassHelperService { $entity->unsetThirdPartySetting('block_class', 'classes'); } // If there is no custom attributes, unset the Third Party Setting. if (empty($entity->getThirdPartySetting('block_class', 'custom_attributes'))) { $entity->unsetThirdPartySetting('block_class', 'custom_attributes'); // If there is no attributes, unset the Third Party Setting. if (empty($entity->getThirdPartySetting('block_class', 'attributes'))) { $entity->unsetThirdPartySetting('block_class', 'attributes'); } // Get the config object. Loading Loading @@ -245,9 +245,9 @@ class BlockClassHelperService { // Load the block by ID. $block = Block::load($variables['elements']['#id']); if (!empty($block->getThirdPartySetting('block_class', 'custom_attributes'))) { if (!empty($block->getThirdPartySetting('block_class', 'attributes'))) { $attributes = $block->getThirdPartySetting('block_class', 'custom_attributes'); $attributes = $block->getThirdPartySetting('block_class', 'attributes'); $attributes = explode('|', $attributes); Loading Loading @@ -323,12 +323,21 @@ class BlockClassHelperService { '#maxlength' => $maxlength_block_class_field, ]; if (!empty($config->get('enable_custom_attributes'))) { $form['third_party_settings']['block_class']['custom_attributes'] = [ '#type' => 'textfield', '#title' => $this->t('Custom Attributes'), '#description' => $this->t('Here you can insert any attributes, for example: data-attribute-invite=new-data'), '#default_value' => $block->getThirdPartySetting('block_class', 'custom_attributes'), if (!empty($config->get('enable_attributes'))) { // Default field type. $field_type_attributes = 'textarea'; // Get the field type if exists. if (!empty($config->get('field_type_attributes'))) { $field_type_attributes = $config->get('field_type_attributes'); } $form['third_party_settings']['block_class']['attributes'] = [ '#type' => $field_type_attributes, '#title' => $this->t('Attributes'), '#description' => $this->t('Here you can insert any attributes, use one per line. For example: data-block-type|info'), '#default_value' => $block->getThirdPartySetting('block_class', 'attributes'), '#maxlength' => 255, ]; } Loading