Fix the issues reported by phpcs on custom google maps block module

Created on 25 April 2023, over 1 year ago
Updated 5 March 2024, 10 months ago

PHPCS

./vendor/bin/phpcs   --standard="Drupal,DrupalPractice" -n   --extensions="php,module,inc,install,test,profile,theme"   web/modules/contrib/custom_google_maps_block/
FILE: /home/shivsharma/project/my-drupal10-site/web/modules/contrib/custom_google_maps_block/src/Form/MapsForm.php
------------------------------------------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
------------------------------------------------------------------------------------------------------------------
 8 | ERROR | Doc comment is empty
------------------------------------------------------------------------------------------------------------------

FILE: /home/shivsharma/project/my-drupal10-site/web/modules/contrib/custom_google_maps_block/src/Plugin/Block/MapsBlock.php
----------------------------------------------------------------------------------------------------------------------------------------------
FOUND 203 ERRORS AFFECTING 173 LINES
----------------------------------------------------------------------------------------------------------------------------------------------
   8 | ERROR | [x] There must be one blank line after the last USE statement; 2 found;
  21 | ERROR | [x] Opening brace should be on the same line as the declaration
  23 | ERROR | [x] Line indented incorrectly; expected 2 spaces, found 4
  26 | ERROR | [x] Line indented incorrectly; expected 2 spaces, found 4
  27 | ERROR | [x] Opening brace should be on the same line as the declaration
  28 | ERROR | [x] Line indented incorrectly; expected 4 spaces, found 8
  29 | ERROR | [x] Line indented incorrectly; expected 4 spaces, found 8
  30 | ERROR | [x] Array indentation error, expected 10 spaces but found 12
  31 | ERROR | [x] Array indentation error, expected 10 spaces but found 12
  32 | ERROR | [x] Array indentation error, expected 10 spaces but found 12
  33 | ERROR | [x] Array indentation error, expected 10 spaces but found 12
  34 | ERROR | [x] Array indentation error, expected 10 spaces but found 12
  35 | ERROR | [x] Array indentation error, expected 10 spaces but found 12
  36 | ERROR | [x] Array indentation error, expected 10 spaces but found 12
  37 | ERROR | [x] Array indentation error, expected 10 spaces but found 12
  38 | ERROR | [x] Array indentation error, expected 10 spaces but found 12
  39 | ERROR | [x] Array indentation error, expected 10 spaces but found 12
  40 | ERROR | [x] Array indentation error, expected 10 spaces but found 12
  41 | ERROR | [x] Array indentation error, expected 10 spaces but found 12
  42 | ERROR | [x] Array indentation error, expected 10 spaces but found 12
  43 | ERROR | [x] Array indentation error, expected 10 spaces but found 12
  44 | ERROR | [x] Array indentation error, expected 10 spaces but found 12
  47 | ERROR | [x] Line indented incorrectly; expected 2 spaces, found 4
  49 | ERROR | [x] Line indented incorrectly; expected 2 spaces, found 4
  52 | ERROR | [x] Line indented incorrectly; expected 2 spaces, found 4
  53 | ERROR | [x] Opening brace should be on the same line as the declaration
  54 | ERROR | [x] Line indented incorrectly; expected 4 spaces, found 8
  56 | ERROR | [x] Line indented incorrectly; expected 4 spaces, found 8
  57 | ERROR | [x] Line indented incorrectly; expected 6 spaces, found 12
  58 | ERROR | [x] Line indented incorrectly; expected 6 spaces, found 12
  59 | ERROR | [x] Line indented incorrectly; expected 4 spaces, found 8
  59 | ERROR | [x] Expected newline after closing brace
  60 | ERROR | [x] Line indented incorrectly; expected 6 spaces, found 12
  61 | ERROR | [x] Line indented incorrectly; expected 4 spaces, found 8
  62 | ERROR | [x] Functions must not contain multiple empty lines in a row; found 2 empty lines
  64 | ERROR | [x] Line indented incorrectly; expected 4 spaces, found 8
  64 | ERROR | [x] Short array syntax must be used to define arrays
  65 | ERROR | [x] Array indentation error, expected 10 spaces but found 12
  66 | ERROR | [x] Array indentation error, expected 10 spaces but found 12
  67 | ERROR | [x] Array indentation error, expected 10 spaces but found 12
  68 | ERROR | [x] Array indentation error, expected 10 spaces but found 12
  69 | ERROR | [x] Array indentation error, expected 10 spaces but found 12
  70 | ERROR | [x] Array indentation error, expected 10 spaces but found 12
  71 | ERROR | [x] Array indentation error, expected 10 spaces but found 12
  72 | ERROR | [x] Array indentation error, expected 10 spaces but found 12
  72 | ERROR | [x] Short array syntax must be used to define arrays
  73 | ERROR | [x] Short array syntax must be used to define arrays
  74 | ERROR | [x] Array indentation error, expected 18 spaces but found 20
  77 | ERROR | [x] Array indentation error, expected 18 spaces but found 20
  78 | ERROR | [x] Array indentation error, expected 18 spaces but found 20
  79 | ERROR | [x] Array indentation error, expected 18 spaces but found 20
  80 | ERROR | [x] Array indentation error, expected 18 spaces but found 20
  81 | ERROR | [x] Array indentation error, expected 18 spaces but found 20
  82 | ERROR | [x] Array indentation error, expected 18 spaces but found 20
  83 | ERROR | [x] Array indentation error, expected 18 spaces but found 20
  84 | ERROR | [x] Array indentation error, expected 18 spaces but found 20
  85 | ERROR | [x] Array indentation error, expected 18 spaces but found 20
  86 | ERROR | [x] Array indentation error, expected 18 spaces but found 20
  87 | ERROR | [x] Array indentation error, expected 18 spaces but found 20
  91 | ERROR | [x] Functions must not contain multiple empty lines in a row; found 2 empty lines
  93 | ERROR | [x] Line indented incorrectly; expected 2 spaces, found 4
  93 | ERROR | [x] Expected 1 blank line after function; 2 found
  96 | ERROR | [x] Line indented incorrectly; expected 2 spaces, found 4
  98 | ERROR | [x] There must be no blank lines after the function comment
  99 | ERROR | [x] Line indented incorrectly; expected 2 spaces, found 4
  99 | ERROR | [x] Scope keyword "public" must be followed by a single space; found newline
 100 | ERROR | [x] Visibility must be declared on method "blockForm"
 100 | ERROR | [x] Expected 1 blank line before function; 0 found
 101 | ERROR | [x] Opening brace should be on the same line as the declaration
 102 | ERROR | [x] Line indented incorrectly; expected 4 spaces, found 8
 103 | ERROR | [x] Line indented incorrectly; expected 4 spaces, found 8
 104 | ERROR | [x] Line indented incorrectly; expected 4 spaces, found 8
 105 | ERROR | [x] Array indentation error, expected 10 spaces but found 12
 106 | ERROR | [x] Array indentation error, expected 10 spaces but found 12
 107 | ERROR | [x] Array indentation error, expected 10 spaces but found 12
 108 | ERROR | [x] Array indentation error, expected 10 spaces but found 12
 108 | ERROR | [x] Use null coalesce operator instead of ternary operator.
 110 | ERROR | [x] Line indented incorrectly; expected 4 spaces, found 8
 111 | ERROR | [x] Array indentation error, expected 10 spaces but found 12
 112 | ERROR | [x] Array indentation error, expected 10 spaces but found 12
 113 | ERROR | [x] Array indentation error, expected 10 spaces but found 12
 114 | ERROR | [x] Array indentation error, expected 10 spaces but found 12
 114 | ERROR | [x] Use null coalesce operator instead of ternary operator.
 116 | ERROR | [x] Line indented incorrectly; expected 4 spaces, found 8
 117 | ERROR | [x] Array indentation error, expected 10 spaces but found 12
 118 | ERROR | [x] Array indentation error, expected 10 spaces but found 12
 119 | ERROR | [x] Array indentation error, expected 10 spaces but found 12
 119 | ERROR | [x] Use null coalesce operator instead of ternary operator.
 122 | ERROR | [x] Line indented incorrectly; expected 4 spaces, found 8
 123 | ERROR | [x] Array indentation error, expected 10 spaces but found 12
 124 | ERROR | [x] Array indentation error, expected 10 spaces but found 12
 125 | ERROR | [x] Array indentation error, expected 10 spaces but found 12
 126 | ERROR | [x] Array indentation error, expected 10 spaces but found 12
 127 | ERROR | [x] Array indentation error, expected 10 spaces but found 12
 127 | ERROR | [x] Use null coalesce operator instead of ternary operator.
 129 | ERROR | [x] Line indented incorrectly; expected 4 spaces, found 8
 129 | ERROR | [x] Short array syntax must be used to define arrays
 130 | ERROR | [x] Array indentation error, expected 10 spaces but found 12
 131 | ERROR | [x] Array indentation error, expected 10 spaces but found 12
 132 | ERROR | [x] Array indentation error, expected 10 spaces but found 12
 133 | ERROR | [x] Array indentation error, expected 10 spaces but found 12
 133 | ERROR | [x] Short array syntax must be used to define arrays
 134 | ERROR | [x] Array indentation error, expected 14 spaces but found 16
 135 | ERROR | [x] Array indentation error, expected 14 spaces but found 16
 136 | ERROR | [x] Array indentation error, expected 14 spaces but found 16
 138 | ERROR | [x] Array indentation error, expected 10 spaces but found 12
 138 | ERROR | [x] Use null coalesce operator instead of ternary operator.
 140 | ERROR | [x] Line indented incorrectly; expected 4 spaces, found 8
 140 | ERROR | [x] Short array syntax must be used to define arrays
 141 | ERROR | [x] Array indentation error, expected 10 spaces but found 12
 142 | ERROR | [x] Array indentation error, expected 10 spaces but found 12
 143 | ERROR | [x] Array indentation error, expected 10 spaces but found 12
 144 | ERROR | [x] Array indentation error, expected 10 spaces but found 12
 144 | ERROR | [x] Use null coalesce operator instead of ternary operator.
 146 | ERROR | [x] Line indented incorrectly; expected 4 spaces, found 8
 146 | ERROR | [x] Short array syntax must be used to define arrays
 152 | ERROR | [x] Use null coalesce operator instead of ternary operator.
 153 | ERROR | [x] Short array syntax must be used to define arrays
 154 | ERROR | [x] Array indentation error, expected 14 spaces but found 16
 154 | ERROR | [x] Short array syntax must be used to define arrays
 155 | ERROR | [x] Array indentation error, expected 14 spaces but found 16
 155 | ERROR | [x] Short array syntax must be used to define arrays
 157 | ERROR | [x] Short array syntax must be used to define arrays
 158 | ERROR | [x] Short array syntax must be used to define arrays
 159 | ERROR | [x] Array indentation error, expected 18 spaces but found 20
 159 | ERROR | [x] Short array syntax must be used to define arrays
 163 | ERROR | [x] Line indented incorrectly; expected 4 spaces, found 8
 167 | ERROR | [x] Use null coalesce operator instead of ternary operator.
 170 | ERROR | [x] Line indented incorrectly; expected 4 spaces, found 8
 171 | ERROR | [x] Array indentation error, expected 10 spaces but found 12
 172 | ERROR | [x] Array indentation error, expected 10 spaces but found 12
 173 | ERROR | [x] Array indentation error, expected 10 spaces but found 12
 174 | ERROR | [x] Array indentation error, expected 10 spaces but found 12
 175 | ERROR | [x] Array indentation error, expected 10 spaces but found 12
 175 | ERROR | [x] Use null coalesce operator instead of ternary operator.
 177 | ERROR | [x] Line indented incorrectly; expected 4 spaces, found 8
 178 | ERROR | [x] Array indentation error, expected 10 spaces but found 12
 179 | ERROR | [x] Array indentation error, expected 10 spaces but found 12
 180 | ERROR | [x] Array indentation error, expected 10 spaces but found 12
 181 | ERROR | [x] Array indentation error, expected 10 spaces but found 12
 181 | ERROR | [x] Use null coalesce operator instead of ternary operator.
 183 | ERROR | [x] Line indented incorrectly; expected 4 spaces, found 8
 184 | ERROR | [x] Array indentation error, expected 10 spaces but found 12
 185 | ERROR | [x] Array indentation error, expected 10 spaces but found 12
 186 | ERROR | [x] Array indentation error, expected 10 spaces but found 12
 187 | ERROR | [x] Array indentation error, expected 10 spaces but found 12
 187 | ERROR | [x] Use null coalesce operator instead of ternary operator.
 189 | ERROR | [x] Functions must not contain multiple empty lines in a row; found 2 empty lines
 191 | ERROR | [x] Line indented incorrectly; expected 4 spaces, found 8
 191 | ERROR | [x] Short array syntax must be used to define arrays
 192 | ERROR | [x] Array indentation error, expected 10 spaces but found 12
 193 | ERROR | [x] Array indentation error, expected 10 spaces but found 12
 194 | ERROR | [x] Array indentation error, expected 10 spaces but found 12
 195 | ERROR | [x] Array indentation error, expected 10 spaces but found 12
 195 | ERROR | [x] Short array syntax must be used to define arrays
 196 | ERROR | [x] Array indentation error, expected 14 spaces but found 16
 197 | ERROR | [x] Array indentation error, expected 14 spaces but found 16
 198 | ERROR | [x] Array indentation error, expected 14 spaces but found 16
 200 | ERROR | [x] Array indentation error, expected 10 spaces but found 12
 200 | ERROR | [x] Use null coalesce operator instead of ternary operator.
 202 | ERROR | [x] Line indented incorrectly; expected 4 spaces, found 8
 206 | ERROR | [x] Use null coalesce operator instead of ternary operator.
 210 | ERROR | [x] Line indented incorrectly; expected 4 spaces, found 8
 214 | ERROR | [x] Use null coalesce operator instead of ternary operator.
 217 | ERROR | [x] Line indented incorrectly; expected 4 spaces, found 8
 218 | ERROR | [x] Array indentation error, expected 10 spaces but found 12
 219 | ERROR | [x] Array indentation error, expected 10 spaces but found 12
 220 | ERROR | [x] Array indentation error, expected 10 spaces but found 12
 221 | ERROR | [x] Array indentation error, expected 10 spaces but found 12
 221 | ERROR | [x] Use null coalesce operator instead of ternary operator.
 224 | ERROR | [x] Line indented incorrectly; expected 4 spaces, found 8
 228 | ERROR | [x] Use null coalesce operator instead of ternary operator.
 231 | ERROR | [x] Functions must not contain multiple empty lines in a row; found 2 empty lines
 233 | ERROR | [x] Line indented incorrectly; expected 4 spaces, found 8
 234 | ERROR | [x] Expected 1 blank line after function; 2 found
 237 | ERROR | [x] Scope keyword "public" must be followed by a single space; found newline
 238 | ERROR | [x] Missing function doc comment
 238 | ERROR | [x] Visibility must be declared on method "blockSubmit"
 238 | ERROR | [x] Expected 1 blank line before function; 0 found
 239 | ERROR | [x] Opening brace should be on the same line as the declaration
 240 | ERROR | [x] Line indented incorrectly; expected 6 spaces, found 8
 241 | ERROR | [x] Line indented incorrectly; expected 6 spaces, found 8
 242 | ERROR | [x] Line indented incorrectly; expected 6 spaces, found 8
 243 | ERROR | [x] Line indented incorrectly; expected 6 spaces, found 8
 244 | ERROR | [x] Line indented incorrectly; expected 6 spaces, found 8
 245 | ERROR | [x] Line indented incorrectly; expected 6 spaces, found 8
 246 | ERROR | [x] Line indented incorrectly; expected 6 spaces, found 8
 247 | ERROR | [x] Line indented incorrectly; expected 6 spaces, found 8
 248 | ERROR | [x] Line indented incorrectly; expected 6 spaces, found 8
 249 | ERROR | [x] Line indented incorrectly; expected 6 spaces, found 8
 250 | ERROR | [x] Line indented incorrectly; expected 6 spaces, found 8
 251 | ERROR | [x] Line indented incorrectly; expected 6 spaces, found 8
 252 | ERROR | [x] Line indented incorrectly; expected 6 spaces, found 8
 253 | ERROR | [x] Line indented incorrectly; expected 6 spaces, found 8
 254 | ERROR | [x] Line indented incorrectly; expected 6 spaces, found 8
 255 | ERROR | [x] Line indented incorrectly; expected 6 spaces, found 8
 256 | ERROR | [x] Line indented incorrectly; expected 6 spaces, found 8
 257 | ERROR | [x] Line indented incorrectly; expected 6 spaces, found 8
 258 | ERROR | [x] Line indented incorrectly; expected 6 spaces, found 8
 258 | ERROR | [x] No space found before comment text; expected "// dsm($values['enable_marker']);" but found
     |       |     "//dsm($values['enable_marker']);"
 258 | ERROR | [x] Inline comments must end in full-stops, exclamation marks, question marks, colons, or closing parentheses
 259 | ERROR | [x] Functions must not contain multiple empty lines in a row; found 2 empty lines
 261 | ERROR | [x] Expected 1 blank line after function; 2 found
----------------------------------------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 203 MARKED SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------------------------------------------------------------------------------

FILE: /home/shivsharma/project/my-drupal10-site/web/modules/contrib/custom_google_maps_block/custom_google_maps_block.module
----------------------------------------------------------------------------------------------------------------------------
FOUND 17 ERRORS AFFECTING 16 LINES
----------------------------------------------------------------------------------------------------------------------------
  1 | ERROR | [x] Missing file doc comment
  7 | ERROR | [x] Opening brace should be on the same line as the declaration
  8 | ERROR | [x] Line indented incorrectly; expected 2 spaces, found 4
  8 | ERROR | [x] Short array syntax must be used to define arrays
  9 | ERROR | [x] Short array syntax must be used to define arrays
 10 | ERROR | [x] Short array syntax must be used to define arrays
 11 | ERROR | [x] Array indentation error, expected 14 spaces but found 16
 12 | ERROR | [x] Array indentation error, expected 14 spaces but found 16
 13 | ERROR | [x] Array indentation error, expected 14 spaces but found 16
 14 | ERROR | [x] Array indentation error, expected 14 spaces but found 16
 15 | ERROR | [x] Array indentation error, expected 14 spaces but found 16
 16 | ERROR | [x] Array indentation error, expected 14 spaces but found 16
 20 | ERROR | [x] Expected 1 blank line after function; 2 found
 23 | ERROR | [x] Missing function doc comment
 24 | ERROR | [x] Opening brace should be on the same line as the declaration
 25 | ERROR | [x] Line indented incorrectly; expected 2 spaces, found 4
 26 | ERROR | [x] Line indented incorrectly; expected 2 spaces, found 4
----------------------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 17 MARKED SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------------------------------------------------------------

Time: 168ms; Memory: 12MB

Steps to reproduce

Exected PHPCS with Drupal Stranded

vendor/bin/phpcs   --standard="Drupal,DrupalPractice" -n   --extensions="php,module,inc,install,test,profile,theme"   web/modules/contrib/custom_google_maps_block/

Proposed resolution

Created a patch.

📌 Task
Status

Needs review

Version

1.0

Component

Code

Created by

🇮🇳India Shiv_Sharma

Live updates comments and jobs are added and updated live.
  • Coding standards

    It involves compliance with, or the content of coding standards. Requires broad community agreement.

Sign in to follow issues

Merge Requests

Comments & Activities

  • Issue created by @Shiv_Sharma
  • Status changed to Needs work over 1 year ago
  • 🇮🇹Italy apaderno Brescia, 🇮🇹

    The issue summary should always describe what the issue is trying to fix and, in the case, of coding standards issues, show which command has been used, which arguments have been used, and which report that command shown.

  • 🇮🇹Italy apaderno Brescia, 🇮🇹
    +/**
    + * @file
    + * This module is used to create a custom Google Map Block.
    + */

    The usual short description is Hook implementations for the Custom Google Maps block.

    +function custom_google_maps_block_theme($existing, $type, $theme, $path) {
    +  return [
    +        'maps' => [
    +            'variables' => [
    +              'width' => NULL,
    +              'height' => NULL,
    +              'border' => NULL,
    +              'border_radius' => NULL,
    +              'color_border' => NULL,
    +              'padding_maps' => NULL,
    +            ]
    +        ]
    +    ];

    The indentation is wrong, since it needs to be increased of two spaces each time.

    +/**
    + * Class Maps form block.
    + */

    The short description does not describe the class.
    Maps is misspelled, since it is not at the beginning of the sentence.
    That class is for a form, not a block.

    +  /**
    +   * Gets the configuration names that will be editable.
    +   *
    +   * @return array
    +   *   An array of configuration object names that are editable if called in
    +   *   conjunction with the trait's config() method.
    +   */

    Since that is a method inherited from a parent class or defined in an interface, the documentation comment does not need to give all that data.

    +      '#attached' => [
    +              'library' => [
    +                'maps/maps_style',
    +              ],
    +              'drupalSettings' => [
    +                'zoom' => $config['zoom_level'],
    +                'center' => $config['center_position'],
    +                'animate_marker_position' => $config['animate_marker_position'],
    +                'enable_marker' => $config['enable_marker'],
    +                'logo_marker' => $image,
    +                'size_logo' => $config['size_logo'],
    +                'title_marker' => $config['title_marker'],
    +                'description_marker' => $config['description_marker'],
    +                'position_marker' => $config['position_marker'],
    +                'animate_marker' => $config['animate_marker'],
    +                'maps_key' => $config['maps_key'],
    +              ]
    +          ],
    +    ];

    The indentation is wrong.

    What I reported in the previous comment still holds true.

  • 🇮🇳India Shiv_Sharma

    @apaderno indentation was fixed by the the PHPCS script.

  • 🇮🇹Italy apaderno Brescia, 🇮🇹

    Even in that case, it still wrong.

  • Status changed to Needs review over 1 year ago
  • 🇮🇳India Shiv_Sharma

    fixed the indentation issue.
    added the patch for same. also added screenshot from PHPCS.

  • Status changed to Needs work over 1 year ago
  • 🇮🇹Italy apaderno Brescia, 🇮🇹
    +  /**
    +   * Gets the configuration names that will be editable.
    +   *
    +   * @return array
    +   *   An array of configuration object names that are editable if called in
    +   *   conjunction with the trait's config() method.
    +   */
    +  protected function getEditableConfigNames() {

    Since that is a method inherited from a parent class or defined in an interface, the documentation comment does not need to give all that data. That is when {@inheritdoc} is used.

    +  /**
    +   * {@inheritdoc}
    +   */
    +  public function submitForm(array &$form, FormStateInterface $form_state) {
    +    $config = $this->config('maps.settings');
    +    $config->set('maps_key', $form_state->getValue('maps_key'));
    +    $config->save();
    +    parent::submitForm($form, $form_state);
    +  }
    +  /**
    +   * {@inheritdoc}
    +   */
    +  public function submitForm(array &$form, FormStateInterface $form_state) {
    +    $config = $this->config('maps.settings');
    +    $config->set('maps_key', $form_state->getValue('maps_key'));
    +    $config->save();
    +    parent::submitForm($form, $form_state);
    +  }

    It is sufficient to use method chaining.

    public function submitForm(array &$form, FormStateInterface $form_state) {
      $this->config('maps.settings')
        ->set('maps_key', $form_state->getValue('maps_key'))
        ->save();
       parent::submitForm($form, $form_state);
    }
    
  • Status changed to Needs review over 1 year ago
  • 🇮🇳India Shiv_Sharma

    @apaderno Patch updated.

  • Status changed to Needs work over 1 year ago
  • 🇮🇹Italy apaderno Brescia, 🇮🇹
    +/**
    + * @file
    + * This is the module to create a google map block.
    + */
    +

    The usual short description is Hook implementations for the Custom Google Maps block module.

    +/**
    + * Class MapsForm. The config form for the google maps block.

    The config form for the Google maps block. is sufficient, since the class description must not start with Class nor repeat the class name.

     /**
    - * Provides a 'Hello' Block.
    + * Provides a 'MapsBlock' Block.

    The correct description is Provides a Google maps block.

  • Status changed to Needs review over 1 year ago
  • 🇮🇳India Soham Sengupta

    Hi, I have updated the patch with the changes.

  • 🇮🇳India Shiv_Sharma

    @apaderno
    as per your feedback updated the patch

  • Status changed to Needs work 11 months ago
  • Hi, patch #11 failed to apply.

    $ git apply 3356331-11.patch -v
    Checking patch custom_google_maps_block.module...
    error: while searching for:
    <?php
    
    /**
     * Implements hook_theme().
     */
    function custom_google_maps_block_theme($existing, $type, $theme, $path)
    {
        return array(
            'maps' => array(
                'variables' => array(
                    'width' => NULL,
                    'height' => NULL,
                    'border' => NULL,
                    'border_radius' => NULL,
                    'color_border' => NULL,
                    'padding_maps' => NULL,
                )
            )
        );
    }
    
    
    function custom_google_maps_block_preprocess_page(&$variables)
    {
        $config = \Drupal::config('maps.settings');
        $variables['#attached']['drupalSettings']['maps_key'] = $config->get('maps_key');
    }
    
    error: patch failed: custom_google_maps_block.module:1
    error: custom_google_maps_block.module: patch does not apply
    Checking patch src/Form/MapsForm.php...
    error: while searching for:
    use Drupal\Core\Form\ConfigFormBase;
    use Drupal\Core\Form\FormStateInterface;
    
    class MapsForm extends ConfigFormBase
    {
    
        /**
         * {@inheritdoc}
         */
        public function getFormId()
        {
            return 'maps_form';
        }
    
        /**
         * Gets the configuration names that will be editable.
         *
         * @return array
         *   An array of configuration object names that are editable if called in
         *   conjunction with the trait's config() method.
         */
        protected function getEditableConfigNames()
        {
            return [
                'maps.settings',
            ];
        }
    
        /**
         * {@inheritdoc}
         */
        public function buildForm(array $form, FormStateInterface $form_state)
        {
            $form = parent::buildForm($form, $form_state);
            $config = $this->config('maps.settings');
    
            $form['maps_key'] = array(
                '#type' => 'textfield',
                '#title' => $this->t('api key for google map'),
                '#required' => TRUE,
                '#default_value' => $config->get('maps_key'),
                '#description' => $this->t('Go to <a target="_blank" href="https://console.developers.google.com">https://console.developers.google.com</a> to get a free API key'),
            );
    
            return $form;
        }
    
        /**
         * {@inheritdoc}
         */
        public function validateForm(array &$form, FormStateInterface $form_state)
        {
            $maps_key = $form_state->getValue('maps_key');
    
            if (empty($maps_key)) {
                $form_state->setErrorByName('maps_key', $this->t('this field is required '));
            }
        }
    
        /**
         * {@inheritdoc}
         */
        public function submitForm(array &$form, FormStateInterface $form_state)
        {
            $config = $this->config('maps.settings');
            $config->set('maps_key', $form_state->getValue('maps_key'));
            $config->save();
            parent::submitForm($form, $form_state);
        }
    
    
    }
    
    error: patch failed: src/Form/MapsForm.php:5
    error: src/Form/MapsForm.php: patch does not apply
    Checking patch src/Plugin/Block/MapsBlock.php...
    

    So changing the status to Needs work.
    Thankyou.

  • First commit to issue fork.
  • Status changed to Needs review 11 months ago
  • 🇮🇳India bharath-kondeti Hyderabad

    Addressed review and moved changes to a PR. Moving the issue to Needs Review

  • First commit to issue fork.
  • First commit to issue fork.
  • I ran the command phpcs --standard=Drupal,DrupalPractice --extensions=php,module,inc,install,test,profile,theme,css,info,txt,md,yml,twig and found no phpcs errors

Production build 0.71.5 2024