Skip to content
Snippets Groups Projects
Commit 25dae3fd authored by Andrii Chyrskyi's avatar Andrii Chyrskyi Committed by Andrii Chyrskyi
Browse files

Merge pull request #2820 from goalgorilla/feature/3270363-profile-summary

Issue #3270363 by chmez: As a LU I want to add a short description about myself
parent d64465a9
No related branches found
No related tags found
Loading
......@@ -14,6 +14,7 @@ profile_profile_field_profile_phone_number: true
profile_profile_field_profile_profile_tag: true
profile_profile_field_profile_self_introduction: true
profile_profile_field_profile_show_email: null
profile_profile_field_profile_summary: true
profile_address_field_city: true
profile_address_field_address: true
profile_address_field_postalcode: true
......
......@@ -616,3 +616,34 @@ function social_profile_update_11007(array &$sandbox): void {
}
}
}
/**
* Add a field for a short description.
*/
function social_profile_update_11201(array &$sandbox): string {
$entity_type_ids = [
'field.storage.profile.field_profile_' => 'field_storage_config',
'field.field.profile.profile.field_profile_' => 'field_config',
];
$path = drupal_get_path('module', 'social_profile') . '/config/static/';
foreach ($entity_type_ids as $prefix => $entity_type_id) {
$config_file = $path . $prefix . 'summary_11201.yml';
$settings = Yaml::parseFile($config_file);
/** @var \Drupal\Core\Config\Entity\ConfigEntityStorageInterface $storage */
$storage = \Drupal::entityTypeManager()->getStorage($entity_type_id);
$storage->createFromStorageRecord($settings)->save();
}
/** @var \Drupal\update_helper\UpdaterInterface $update_helper */
$update_helper = \Drupal::service('update_helper.updater');
// Execute configuration update definitions with logging of success.
$update_helper->executeUpdate('social_profile', __FUNCTION__);
// Output logged messages to related channel of update execution.
return $update_helper->logger()->output();
}
<?php
namespace Drupal\social_profile\Plugin\Field\FieldWidget;
use Drupal\Core\Field\FieldItemListInterface;
use Drupal\Core\Field\Plugin\Field\FieldWidget\StringTextfieldWidget;
use Drupal\Core\Form\FormStateInterface;
/**
* Plugin implementation of the 'social_profile_string_textarea' widget.
*
* @FieldWidget(
* id = "social_profile_string_textarea",
* label = @Translation("Textarea"),
* field_types = {
* "string"
* }
* )
*/
class SocialProfileStringTextareaWidget extends StringTextfieldWidget {
/**
* {@inheritdoc}
*/
public function formElement(
FieldItemListInterface $items,
$delta,
array $element,
array &$form,
FormStateInterface $form_state
) {
$element = parent::formElement($items, $delta, $element, $form, $form_state);
$element['value']['#type'] = 'textarea';
return $element;
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment