Remove duplicated assignment for contextRepository in ConditionAddForm

Created on 27 August 2024, 4 months ago

Problem/Motivation

In πŸ› phpstan fixes: dynamic call to static method + fail to call parent constructor Fixed a call to the parent constructor has been added to ConditionAddForm
The parent constructor is already assigning $this->contextRepository = $context_repository;
I think this assignment in ConditionAddForm can be safely removed...

Proposed resolution

Resolution #1:
- Simply remove $this->contextRepository = $context_repository; from ConditionAddForm

Resolution #2:
- Remove the __construct method from ConditionAddForm
- Use create method for the extra arguments, as follows:

  /**
   * {@inheritdoc}
   */
  public static function create(ContainerInterface $container) {
    $instance = parent::create($container);
    $instance->conditionManager = $container->get('plugin.manager.condition');
    return $instance;
  }

By doing this, we won't need to babysit the child class when the parent class introduces new changes to the constructor...
Note: websites that are extending ConditionAddForm class might be effected by this change.

πŸ“Œ Task
Status

Active

Version

2.0

Component

Code

Created by

πŸ‡§πŸ‡ͺBelgium msnassar

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

Merge Requests

Comments & Activities

Production build 0.71.5 2024