\Drupal::service('router.builder')->rebuild() call should be avoided in classes, Use dependency injection instead in drupal Database

Created on 25 May 2023, about 1 year ago
Updated 2 June 2023, about 1 year ago

Proposed resolution

Fix the following coding standards issues and upload the patch or create an MR with fixes.


FILE: \modules\contrib\fakelogin\src\Form\FakeLoginConfigForm.php
------------------------------------------------------------------------------

 58 | WARNING | \Drupal calls should be avoided in classes, use dependency injection instead
------------------------------------------------------------------------------
📌 Task
Status

Closed: duplicate

Version

1.0

Component

Code

Created by

🇮🇳India Shanu Chouhan

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

Comments & Activities

  • Issue created by @Shanu Chouhan
  • Issue was unassigned.
  • Status changed to Needs review about 1 year ago
  • 🇮🇳India Shanu Chouhan

    I have Created a patch to fix this issue.

  • Status changed to Needs work about 1 year ago
  • 🇮🇹Italy apaderno Brescia, 🇮🇹
    +  /**
    +   * Constructs the FakeLoginConfigForm.
    +   *
    +   * @param \Drupal\Core\Routing\RouteBuilderInterface $router_builder
    +   *   The route builder.

    The description for a constructor must start with Constructs a new followed by the class name (including its namespace), and end with object.

    +  /**
    +   * @param ContainerInterface $container
    +   *
    +   * @return static
    +   */
    +  public static function create(ContainerInterface $container) {

    That is not the documentation comment for a method inherited from a parent class or defined in an interface.

  • Status changed to Needs review about 1 year ago
  • 🇮🇳India mrinalini9 New Delhi

    Updated patch #2 by addressing #3, please review it.

    Thanks!

  • Status changed to Needs work about 1 year ago
  • 🇮🇹Italy apaderno Brescia, 🇮🇹
    +  /**
    +   * Constructs a new FakeLoginConfigForm object.
    +   *

    The description for a constructor must start with Constructs a new followed by the class name (including its namespace), and end with object.

  • Assigned to sourabhjain
  • 🇮🇳India sourabhjain

    Let me work on #5.

  • Issue was unassigned.
  • 🇮🇳India sourabhjain

    @apaderno, The description contains all the points which you have described.
    Please let us know what desc you are expecting.

  • 🇮🇹Italy apaderno Brescia, 🇮🇹

    There is no namespace in FakeLoginConfigForm.

  • Status changed to Needs review about 1 year ago
  • 🇮🇳India mrinalini9 New Delhi

    Updated patch #4 by addressing #8, please review it.

    Thanks!

  • 🇮🇹Italy apaderno Brescia, 🇮🇹
    +  /**
    +   * Constructs a new Drupal\fakelogin\Form\FakeLoginConfigForm object.
    +   *
    +   * @param \Drupal\Core\Routing\RouteBuilderInterface $router_builder
    +   *   The route builder.
    +   */
    

    That description contains the class namespace too. The previous change was different.

    +  /**
    +   * Constructs a new FakeLoginConfigForm object.
    +   *
    +   * @param \Drupal\Core\Routing\RouteBuilderInterface $router_builder
    +   *   The route builder.
    +   */
    

    FakeLoginConfigForm alone does not include the class namespace.

  • Status changed to Closed: duplicate about 1 year ago
  • 🇮🇹Italy apaderno Brescia, 🇮🇹

    Since these changes are already applied in another issue, this issue is a duplicate of that issue.

Production build 0.69.0 2024