Commit 8f09eb08 authored by Jeff Hipp's avatar Jeff Hipp
Browse files

Issue #3295118 by anoopsingh92, adaucyj, akshaydalvi212, Abhijith S, Rakhi...

Issue #3295118 by anoopsingh92, adaucyj, akshaydalvi212, Abhijith S, Rakhi Soni, hipp2bsquare, mauryarahul11, atul ghate, emarinho, cedewey: \Drupal calls should be avoided in classes, use dependency injection instead and coding standards
parent e39a7b6a
Loading
Loading
Loading
Loading
+15 −7
Changes for README.md: 15 added lines, 7 removed lines.
Original line number Diff line number Diff line
# Introduction

Maxlength allows site administrators to set hard or soft character limits on titles, text fields and links.
Maxlength allows site administrators to set hard or soft character 
limits on titles, text fields and links.

For a full description of the module visit the [Maxlength Project Page](https://www.drupal.org/project/maxlength)

@@ -14,7 +15,9 @@ We design improvements and prioritize issues based on our vision and values.

## Vision

The Maxlength module helps website authors write concisely to better connect with their audiences and adhere to the character limits defined by the site's design.
The Maxlength module helps website authors write concisely 
to better connect with their audiences and adhere 
to the character limits defined by the site's design.


## Values 
@@ -32,7 +35,8 @@ Visit our [Roadmap](https://www.drupal.org/project/maxlength/issues/3259874) to

## Reporting Bugs and Requesting Features

* To submit bug reports and feature suggestions, visit https://www.drupal.org/project/issues/maxlength
* To submit bug reports and feature suggestions, 
  visit https://www.drupal.org/project/issues/maxlength


# Requirements
@@ -42,15 +46,18 @@ This module requires no modules outside of Drupal core.

# Installation

Install the Maxlength module as you would normally install a contributed Drupal module. 
Install the Maxlength module as you would normally 
install a contributed Drupal module. 
Read the [Installing Modules documentation page](https://www.drupal.org/node/1897420) for more information.


# Configuration

1. Navigate to Administration > Extend and enable the module.
2. Navigate to Administration > Structure > Content types [Content type to edit] > Manage form display.
3. Select the contextual links icon for the desired field and enter the Maxlength. Update and save.
2. Navigate to Administration > Structure > Content types [Content type to edit] 
3. Then Navigate to Content types > Manage form display.
4. Select the contextual links icon for the desired field and enter Maxlength. 
5. Update and save.

For more information read the [Maxlength Documentation](https://www.drupal.org/docs/contributed-modules/maxlength). 

@@ -67,6 +74,7 @@ Supporting organization:

# Credits

Many people have contributed to Maxlength over years. We are grateful to each of them for the work they've put into it.
Many people have contributed to Maxlength over years. 
We are grateful to each of them for the work they've put into it.

Read more about the history of Maxlength at the [Credits documentation page](https://www.drupal.org/docs/contributed-modules/maxlength/credits).
+1 −1
Changes for css/maxlength.css: 1 added line, 1 removed line.
Original line number Diff line number Diff line
.error strong {
  color: #C01C28;
  color: #c01c28;
  font-weight: bold;
}
+1 −1
Changes for maxlength.module: 1 added line, 1 removed line.
Original line number Diff line number Diff line
@@ -19,7 +19,7 @@ function maxlength_help($route_name, RouteMatchInterface $route_match) {
    case 'help.page.maxlength':
      $output = '<h2>' . t('About') . '</h2>';
      $output = '<p>' . t('To configure a character limit, navigate to the <strong>Manage form display</strong> settings page for the field you are setting a limit on. For example, setting a character limit on the Body field of the Article content type would be found at <em>Structure > Content Types > Article > Manage form display</em>.') . '</p>';
      $output .= '<p>' . t('For more information, see the ') . t('<a href="https://www.drupal.org/docs/contributed-modules/maxlength">online documentation for the Maxlength module</a>.') . '</p>';
      $output .= '<p>' . t('For more information, see the @link', ['@link' => '<a href="https://www.drupal.org/docs/contributed-modules/maxlength">online documentation for the Maxlength module</a>.']) . '</p>';
      return $output;
  }
}
+1 −0
Changes for maxlength.services.yml: 1 added line, 0 removed lines.
Original line number Diff line number Diff line
services:
  maxlength.widget_settings:
    class: Drupal\maxlength\WidgetSettings
    arguments: ['@module_handler']
+30 −1
Changes for src/WidgetSettings.php: 30 added lines, 1 removed line.
Original line number Diff line number Diff line
@@ -2,11 +2,40 @@

namespace Drupal\maxlength;

use Drupal\Core\Extension\ModuleHandlerInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;

/**
 * The WidgetManager service.
 */
class WidgetSettings implements WidgetSettingsInterface {

  /**
   * The module handler service.
   *
   * @var \Drupal\Core\Extension\ModuleHandlerInterface
   */
  protected $moduleHandler;

  /**
   * {@inheritdoc}
   *
   * @param \Drupal\Core\Extension\ModuleHandlerInterface $module_handler
   *   The module handler service.
   */
  public function __construct(ModuleHandlerInterface $module_handler) {
    $this->moduleHandler = $module_handler;
  }

  /**
   * {@inheritdoc}
   */
  public static function create(ContainerInterface $container) {
    return new static(
      $container->get('module_handler')
    );
  }

  /**
   * {@inheritdoc}
   */
@@ -54,7 +83,7 @@ class WidgetSettings implements WidgetSettingsInterface {
      ],
    ];

    $additional_widget_settings = \Drupal::moduleHandler()->invokeAll('maxlength_widget_settings') ?: [];
    $additional_widget_settings = $this->moduleHandler->invokeAll('maxlength_widget_settings') ?: [];

    return $settings + $additional_widget_settings;
  }