Access services via DI

Created on 31 July 2020, almost 4 years ago
Updated 11 July 2023, 12 months ago

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

📌 Task
Status

Needs review

Version

1.0

Component

Code

Created by

🇮🇳India niral098 Pune

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • 🇮🇳India sidharth_soman Bangalore

    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.

Production build 0.69.0 2024