FILE: C:\xampp\htdocs\drupal95\web\modules\contrib\gleab\src\Plugin\Block\GleabBlock.php
-----------------------------------------------------------------------------------------------------------------------------------------
FOUND 0 ERRORS AND 5 WARNINGS AFFECTING 4 LINES
-----------------------------------------------------------------------------------------------------------------------------------------
25 | WARNING | \Drupal calls should be avoided in classes, use dependency injection instead
27 | WARNING | \Drupal calls should be avoided in classes, use dependency injection instead
31 | WARNING | \Drupal calls should be avoided in classes, use dependency injection instead
-----------------------------------------------------------------------------------------------------------------------------------------

Comments

Harsh panchal created an issue. See original summary.

Harsh panchal’s picture

Assigned: Harsh panchal » Unassigned
Category: Task » Bug report
Status: Active » Needs review
StatusFileSize
new2.58 KB

I have fixed this issue and providing a patch.

bramdriesen’s picture

Status: Needs review » Needs work
+++ b/src/Plugin/Block/GleabBlock.php
@@ -17,17 +21,65 @@ use Drupal\Core\Link;
+  protected $configFactory;
...
+  protected $currentUser;
...
+  protected $messenger;

Missing types.

+++ b/src/Plugin/Block/GleabBlock.php
@@ -17,17 +21,65 @@ use Drupal\Core\Link;
   public function build() {

Missing return type

+++ b/src/Plugin/Block/GleabBlock.php
@@ -17,17 +21,65 @@ use Drupal\Core\Link;
+        $this->messenger->addError(Markup::create(t('Please fill out the Gleap API key from') . " " . $link));

better to use single quotes

bramdriesen’s picture

Also, instead of concatenating it is possible to use translation parameters to replace a variable in the t string.

qusai taha’s picture

Status: Needs work » Needs review
StatusFileSize
new6.22 KB

Re-Roll patch #2

bramdriesen’s picture

Status: Needs review » Needs work

Nothing of #3 & #4 has been implemented.

pflora’s picture

Status: Needs work » Needs review
StatusFileSize
new6.9 KB

Here's a patch with the requested changes from #3 and #4.

bramdriesen’s picture

Status: Needs review » Needs work

Frist 2 points of #3 still need to be addressed.

protected $configFactory;
Should become
protected ConfigFactoryInterface $configFactory;

+++ b/src/Plugin/Block/GleapBlock.php
@@ -17,24 +22,80 @@ use Drupal\Core\StringTranslation\StringTranslationTrait;
+  /**
+   * The admin Gleap configuration.
+   *
+   * @var \Drupal\Core\Config\Config
+   */
+  protected $config;

Why is this no longer the ConfigFactoryInterface ?

+++ b/README.txt
@@ -9,7 +9,7 @@ CONTENTS OF THIS FILE
+The module makes it easy to integrate with Gleap through the Gleap API key, ¶

No need to add this space/tab here

+++ b/src/Plugin/Block/GleapBlock.php
@@ -17,24 +22,80 @@ use Drupal\Core\StringTranslation\StringTranslationTrait;
+  public function build() {

Still missing the return type. I think it should be array in this case.

public function build(): array {

pflora’s picture

Status: Needs work » Needs review
StatusFileSize
new4.59 KB

@BramDriesen Thank you for your feedback!

Here's the patch with the requested changes. Let me know if i could have done anything better!

ramonvasconcelos’s picture

Assigned: Unassigned » ramonvasconcelos

I'll review it.

ramonvasconcelos’s picture

Assigned: ramonvasconcelos » Unassigned
Status: Needs review » Reviewed & tested by the community

The requests made by @BramDriesen were all done.

bramdriesen’s picture

Status: Reviewed & tested by the community » Needs work
+++ b/src/Plugin/Block/GleapBlock.php
@@ -29,23 +29,23 @@ class GleapBlock extends BlockBase implements ContainerFactoryPluginInterface {
+   * @var \Drupal\Core\Config\Config\ContainerInterface
...
+  protected ContainerInterface $configFactory;

Container interface?

Config !== Container?

ramonvasconcelos’s picture

Assigned: Unassigned » ramonvasconcelos

Sorry i didn't see that. I'll take another look.

ramonvasconcelos’s picture

StatusFileSize
new7.01 KB

Changes done. I corrected the ContainerInterface to ConfigFactoryInterface.
I attached a patch with all the modifications included.

ramonvasconcelos’s picture

Assigned: ramonvasconcelos » Unassigned
Status: Needs work » Needs review
alexanderj’s picture

Assigned: Unassigned » alexanderj

I will review it.

alexanderj’s picture

Assigned: alexanderj » Unassigned
Status: Needs review » Reviewed & tested by the community

I have reviewed the patch and it is working correctly and I believe it is now as expected. moving to RTBC.

bramdriesen’s picture

I didn't test the patch but the patch itself code wise looks good now.

  • e0e0dc4 committed on 1.0.x
    Issue #3305892 by pflora, ramonvasconcelos, Harsh panchal, Qusai Taha,...
ahmad abbad’s picture

Thanks all

ahmad abbad’s picture

Status: Reviewed & tested by the community » Fixed
ahmad abbad’s picture

Status: Fixed » Closed (fixed)