Skip to content
Snippets Groups Projects

Added the configuration for likes text and icon.

Open Sahana N requested to merge issue/like-3502436:3502436-allow-to-configure into 2.x

Closes #3502436

Merge request reports

Loading
Loading

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
94 95 'progress' => ['type' => 'none'],
95 96 ],
96 97 ];
97 $form['label']['icon'] = [
98 '#type' => 'html_tag',
99 '#tag' => 'i',
100 '#attributes' => [
101 'class' => ['fa-solid', 'fa-heart'],
102 ],
103 ];
98 $icon = \Drupal::config('like.settings')->get('image');
99 $file = File::load($icon);
100 $image_url = $file ? $file->createFileUrl() : '';
101 dump($image_url);
  • 94 95 'progress' => ['type' => 'none'],
    95 96 ],
    96 97 ];
    97 $form['label']['icon'] = [
    98 '#type' => 'html_tag',
    99 '#tag' => 'i',
    100 '#attributes' => [
    101 'class' => ['fa-solid', 'fa-heart'],
    102 ],
    103 ];
    98 $icon = \Drupal::config('like.settings')->get('image');
    99 $file = File::load($icon);
    100 $image_url = $file ? $file->createFileUrl() : '';
    101 dump($image_url);
    102 if($file){
  • 98 '#type' => 'html_tag',
    99 '#tag' => 'i',
    100 '#attributes' => [
    101 'class' => ['fa-solid', 'fa-heart'],
    102 ],
    103 ];
    98 $icon = \Drupal::config('like.settings')->get('image');
    99 $file = File::load($icon);
    100 $image_url = $file ? $file->createFileUrl() : '';
    101 dump($image_url);
    102 if($file){
    103 $form['label']['image'] = [
    104 '#type' => 'html_tag',
    105 '#tag' => 'img',
    106 '#attributes' => [
    107 'src' => $image_url,
  • 178 197 * Returns the likes text for the item.
    179 198 */
    180 199 protected function likesTxt(int $value): string {
    181 return $this->t('(<span>@value</span>) Likes', ['@value' => $value]);
    200 $likes = \Drupal::config('like.settings')->get('like_text');
    201 $likes_text = !empty($likes) ? $likes : 'Likes';
    202 return $this->t('(<span>@value</span>) @likes', ['@value' => $value, '@likes' => $likes_text]);
  • 99 100 '#default_value' => $config->get('like_cookie_expiry_time'),
    100 101 ];
    101 102
    103 $form['like_text'] = [
    104 '#type' => 'textfield',
    105 '#title' => $this->t('Like Text'),
    106 '#description' => $this->t('Please enter the text to display'),
    107 '#default_value' => $config->get('like_text'),
    108 ];
    109
    110
    111 if($config->get('image')){
    112 $file = File::load($config->get('image'));
    113 $form['like_icon'] = [
    114 '#type' => 'managed_file',
  • Pedro Cambra requested changes

    requested changes

  • Sahana N added 1 commit

    added 1 commit

    Compare with previous version

  • 120 136 parent::submitForm($form, $form_state);
    121 137 $config = $this->config('like.settings');
    122 138 $config->set('enabled_entity_types', $form_state->getValue('enabled_entity_types'));
    139 $config->set('like_text', $form_state->getValue('like_text'));
  • Prem Suthar added 1 commit

    added 1 commit

    Compare with previous version

  • Prem Suthar added 1 commit

    added 1 commit

    • 16c7e8b9 - removed unwanted use statments.

    Compare with previous version

  • Prem Suthar added 1 commit

    added 1 commit

    Compare with previous version

  • Prem Suthar added 1 commit

    added 1 commit

    • c8f59edc - removed unwanted use statments.

    Compare with previous version

  • 7 7 label: 'Enabled entity types'
    8 8 sequence:
    9 9 type: string
    10 like_text:
    11 type: string
    12 label: 'Like button text'
    13 icon_class:
    14 type: string
    15 label: 'CSS class for like button icon'
    10 16 like_cookie_expiry_time:
    11 17 type: integer
    12 label: 'Like Cookie Expiry Time'
    18 label: 'Cookie expiry time in seconds'
  • 94 95 'progress' => ['type' => 'none'],
    95 96 ],
    96 97 ];
    97 $form['label']['icon'] = [
    98 '#type' => 'html_tag',
    99 '#tag' => 'i',
    100 '#attributes' => [
    101 'class' => ['fa-solid', 'fa-heart'],
    102 ],
    103 ];
    98 $icon = \Drupal::config('like.settings')->get('icon_class');
    99 if($icon) {
  • 178 192 * Returns the likes text for the item.
    179 193 */
    180 194 protected function likesTxt(int $value): string {
    181 return $this->t('(<span>@value</span>) Likes', ['@value' => $value]);
    195 $likes = \Drupal::config('like.settings')->get('like_text');
  • 94 95 'progress' => ['type' => 'none'],
    95 96 ],
    96 97 ];
    97 $form['label']['icon'] = [
    98 '#type' => 'html_tag',
    99 '#tag' => 'i',
    100 '#attributes' => [
    101 'class' => ['fa-solid', 'fa-heart'],
    102 ],
    103 ];
    98 $icon = \Drupal::config('like.settings')->get('icon_class');
  • 99 99 '#default_value' => $config->get('like_cookie_expiry_time'),
    100 100 ];
    101 101
    102 $form['like_text'] = [
    103 '#type' => 'textfield',
    104 '#title' => $this->t('Like Text'),
    105 '#description' => $this->t('Please enter the text to display'),
  • 94 95 'progress' => ['type' => 'none'],
    95 96 ],
    96 97 ];
    97 $form['label']['icon'] = [
    98 '#type' => 'html_tag',
    99 '#tag' => 'i',
    100 '#attributes' => [
    101 'class' => ['fa-solid', 'fa-heart'],
    102 ],
    103 ];
    98 $icon = \Drupal::config('like.settings')->get('icon_class');
    99 if($icon) {
    100 $form['label']['image'] = [
  • Pedro Cambra requested changes

    requested changes

  • Prem Suthar added 1 commit

    added 1 commit

    Compare with previous version

  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Please register or sign in to reply
    Loading