Can we access services via Dependency Injection in LikeForm file instead of using Global services?

CommentFileSizeAuthor
#7 3162683-7.patch3.62 KBsidharth_soman
Command icon 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

niral098 created an issue. See original summary.

joris_lucius’s picture

Yes, that's no problem and better indeed; I'll implement it in next release.

niral098’s picture

Great!

AstonVictor made their first commit to this issue’s fork.

astonvictor’s picture

Status: Active » Needs review

Prepared MR. Implement DI and fixed a lot of code standard issues.

sidharth_soman’s picture

StatusFileSize
new3.62 KB

There were still some errors left in the MR as below:

C:\xampp\htdocs\backendassignment\web\modules\contrib\simple_like_button-3162683>phpcs --standard=Drupal,DrupalPractice --extensions=php,module,inc,install,test,profile,theme,css,info,txt,md,yml,twig simple_like_button-3162683

FILE: C:\xampp\htdocs\backendassignment\web\modules\contrib\simple_like_button-3162683\simple_like_button-3162683\css\simple_like_button.css
--------------------------------------------------------------------------------------------------------------------------------------------
FOUND 2 ERRORS AFFECTING 1 LINE
--------------------------------------------------------------------------------------------------------------------------------------------
 1 | ERROR | [x] End of line character is invalid; expected "\n" but found "\r\n"
 1 | ERROR | [x] Expected 1 space before opening brace of class definition; 0 found
--------------------------------------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 2 MARKED SNIFF VIOLATIONS AUTOMATICALLY
--------------------------------------------------------------------------------------------------------------------------------------------


FILE: C:\xampp\htdocs\backendassignment\web\modules\contrib\simple_like_button-3162683\simple_like_button-3162683\simple_like_button.module
-------------------------------------------------------------------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
-------------------------------------------------------------------------------------------------------------------------------------------
 1 | ERROR | [x] End of line character is invalid; expected "\n" but found "\r\n"
-------------------------------------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
-------------------------------------------------------------------------------------------------------------------------------------------


FILE: C:\xampp\htdocs\backendassignment\web\modules\contrib\simple_like_button-3162683\simple_like_button-3162683\src\Entity\SimpleLike.php
-------------------------------------------------------------------------------------------------------------------------------------------
FOUND 2 ERRORS AFFECTING 2 LINES
-------------------------------------------------------------------------------------------------------------------------------------------
 1 | ERROR | [x] End of line character is invalid; expected "\n" but found "\r\n"
 7 | ERROR | [x] Use statements should be sorted alphabetically. The first wrong one is Drupal\Core\Entity\ContentEntityBase.
-------------------------------------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 2 MARKED SNIFF VIOLATIONS AUTOMATICALLY
-------------------------------------------------------------------------------------------------------------------------------------------


FILE: C:\xampp\htdocs\backendassignment\web\modules\contrib\simple_like_button-3162683\simple_like_button-3162683\src\Entity\SimpleLikeInterface.php
----------------------------------------------------------------------------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
----------------------------------------------------------------------------------------------------------------------------------------------------
 1 | ERROR | [x] End of line character is invalid; expected "\n" but found "\r\n"
----------------------------------------------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------------------------------------------------------------------------------------


FILE: C:\xampp\htdocs\backendassignment\web\modules\contrib\simple_like_button-3162683\simple_like_button-3162683\src\Form\LikeForm.php
----------------------------------------------------------------------------------------------------------------------------------------------
FOUND 2 ERRORS AND 2 WARNINGS AFFECTING 4 LINES
----------------------------------------------------------------------------------------------------------------------------------------------
   1 | ERROR   | [x] End of line character is invalid; expected "\n" but found "\r\n"
  11 | ERROR   | [x] Use statements should be sorted alphabetically. The first wrong one is Drupal\Component\Utility\Html.
  20 | WARNING | [ ] The class short comment should describe what the class does and not simply repeat the class name
 161 | WARNING | [ ] t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
----------------------------------------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 2 MARKED SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------------------------------------------------------------------------------


FILE: C:\xampp\htdocs\backendassignment\web\modules\contrib\simple_like_button-3162683\simple_like_button-3162683\src\Plugin\Block\SimpleLikeButtonBlock.php
------------------------------------------------------------------------------------------------------------------------------------------------------------
FOUND 5 ERRORS AFFECTING 3 LINES
------------------------------------------------------------------------------------------------------------------------------------------------------------
  1 | ERROR | [x] End of line character is invalid; expected "\n" but found "\r\n"
  7 | ERROR | [x] Use statements should be sorted alphabetically. The first wrong one is Drupal\Core\Plugin\ContainerFactoryPluginInterface.
 27 | ERROR | [ ] Parameter $configuration is not described in comment
 27 | ERROR | [ ] Parameter $plugin_id is not described in comment
 27 | ERROR | [ ] Parameter $plugin_definition is not described in comment
------------------------------------------------------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 2 MARKED SNIFF VIOLATIONS AUTOMATICALLY
------------------------------------------------------------------------------------------------------------------------------------------------------------

Time: 1.39 secs; Memory: 6MB

I've fixed them all and provided a patch. Please review.

  • 5ab3aacd committed on 1.0.x
    ref #3162683 - Implement DI
    
joseph.olstad’s picture

Status: Needs review » Fixed

Now that this issue is closed, please review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, please credit people who helped resolve this issue.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.