FILE: /var/www/html/dcontri/charts_twig/src/ChartsTwig.php
---------------------------------------------------------------------------------------------------------------------------------------------
FOUND 2 ERRORS AND 8 WARNINGS AFFECTING 6 LINES
---------------------------------------------------------------------------------------------------------------------------------------------
  1 | ERROR   | [x] The PHP open tag must be followed by exactly one blank line
 29 | ERROR   | [x] You must use "/**" style comments for a function comment
 35 | WARNING | [ ] t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
 35 | WARNING | [ ] Only string literals should be passed to t() where possible
 42 | WARNING | [ ] t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
 42 | WARNING | [ ] Only string literals should be passed to t() where possible
 48 | WARNING | [ ] t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
 48 | WARNING | [ ] Only string literals should be passed to t() where possible
 53 | WARNING | [ ] t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
 53 | WARNING | [ ] Only string literals should be passed to t() where possible
---------------------------------------------------------------------------------------------------------------------------------------------
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

gayatri chahar created an issue. See original summary.

gayatri chahar’s picture

Assigned: gayatri chahar » Unassigned
Issue summary: View changes
Status: Active » Needs review
StatusFileSize
new1.22 KB

Patch created. Please review it

akshay.singh’s picture

Assigned: Unassigned » akshay.singh
Issue summary: View changes

I will review this.

Thanks

akshay.singh’s picture

Title: t() calls should be avoided in class » t() calls should be avoided in classes
Assigned: akshay.singh » Unassigned
Issue summary: View changes
StatusFileSize
new1.7 KB
FILE: /var/www/html/dcontri/charts_twig/src/ChartsTwig.php
--------------------------------------------------------------------------------
FOUND 2 ERRORS AND 4 WARNINGS AFFECTING 6 LINES
--------------------------------------------------------------------------------
  1 | ERROR   | [x] The PHP open tag must be followed by exactly one blank line
 29 | ERROR   | [x] You must use "/**" style comments for a function comment
 35 | WARNING | [ ] Only string literals should be passed to t() where possible
 42 | WARNING | [ ] Only string literals should be passed to t() where possible
 48 | WARNING | [ ] Only string literals should be passed to t() where possible
 53 | WARNING | [ ] Only string literals should be passed to t() where possible
--------------------------------------------------------------------------------

After applying the above patch. I found the string literal issues along with the formatting issues and fixed them.
Please check.

Thanks

hardikpandya’s picture

Status: Needs review » Reviewed & tested by the community

I see the patch is applying and all the issues are fixed. Marking as RTBC.

andileco’s picture

Status: Reviewed & tested by the community » Needs review
StatusFileSize
new2.63 KB

Thank you all for your patches. The base class does not have the string translation method, so it was necessary to add the StringTranslationTrait in order to use $this->t(). I also added a couple adjustments to the docblock, parameters while I was in the code.

andileco’s picture

StatusFileSize
new3 KB

OK, so right after I created the last patch, I did some testing and realized the $this->t() was not getting reached. If you want to translate, you need to use |t or |trans in the Twig code itself. I added documentation in the README. I also replaced $this->t() with Xss::filter() to provide additional controls on the strings that users can input.

  • andileco committed 5735a1da on 1.0.x
    Issue #3336007 by andileco, hardikpandya, gayatri chahar, akshay.singh:...
andileco’s picture

Version: 1.0.0 » 1.0.2
Status: Needs review » Fixed

Status: Fixed » Closed (fixed)

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