Problem/Motivation
- This is created from #3582123: Fix Drupal Coding Standards for 5.1.x
- But this one is focused on Drupal Best Practive
- We need to take care of Dependency Injection
- Is necessary to test if services still working
Steps to reproduce
Run PHPCS
With bestPractice
Verify errors
FILE: modal_page/modal_page.install
-------------------------------------------------------------------------
FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
-------------------------------------------------------------------------
689 | WARNING | There must be no blank line following an inline comment
-------------------------------------------------------------------------
FILE: modal_page/src/Form/ModalForm.php
----------------------------------------------------------------------------------------------------------
FOUND 0 ERRORS AND 2 WARNINGS AFFECTING 2 LINES
----------------------------------------------------------------------------------------------------------
921 | WARNING | Role::loadMultiple calls should be avoided in classes, use dependency injection instead
1232 | WARNING | \Drupal calls should be avoided in classes, use dependency injection instead
----------------------------------------------------------------------------------------------------------
FILE: modal_page/src/Controller/ModalHelpController.php
---------------------------------------------------------------------------------------------
FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
---------------------------------------------------------------------------------------------
81 | WARNING | \Drupal calls should be avoided in classes, use dependency injection instead
---------------------------------------------------------------------------------------------
FILE: modal_page/src/Controller/ModalAjaxController.php
----------------------------------------------------------------------------------------------
FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
----------------------------------------------------------------------------------------------
223 | WARNING | \Drupal calls should be avoided in classes, use dependency injection instead
----------------------------------------------------------------------------------------------
FILE: modal_page/src/Service/ModalPageService.php
----------------------------------------------------------------------------------------------
FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
----------------------------------------------------------------------------------------------
638 | WARNING | \Drupal calls should be avoided in classes, use dependency injection instead
----------------------------------------------------------------------------------------------
FILE: modal_page/src/Service/ModalPageHelperService.php
----------------------------------------------------------------------------------------------
FOUND 0 ERRORS AND 2 WARNINGS AFFECTING 2 LINES
----------------------------------------------------------------------------------------------
309 | WARNING | \Drupal calls should be avoided in classes, use dependency injection instead
312 | WARNING | \Drupal calls should be avoided in classes, use dependency injection instead
----------------------------------------------------------------------------------------------
Time: 757ms; Memory: 14MB
renatog@macbook
Proposed resolution
Fix items
Validate if services still working fine
Notes
- Let's use the most updated version of phpcs and standards "Drupal Coding Standards" and "Drupal Best Practices"
- Just to make sure that we're fixing to the most updated recommendations
- In the future we can add the pipeline to verify that automatically
- For now we can just fix manually
User interface changes
API changes
Data model changes
Issue fork modal_page-3583173
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #4
sapnil_biswas commented