(PHPStan) Deprecate link and url related methods in PluginBase

Created on 13 July 2024, about 2 months ago

Problem/Motivation

\Drupal\feeds\Plugin\Type\PluginBase has a few methods that are calling a Drupal service. These methods are:

  • linkGenerator()
  • urlGenerator()

These methods are called only within the same class by these methods respectively:

  • l()
  • url()

l() is nowhere called in the Feeds code base and url() is only called once by \Drupal\feeds\Feeds\Processor\EntityProcessorBase::entityValidate().

Finally, to support access to these services, there is a method called container() which calls \Drupal::getContainer().

Since the low usage and since this doesn't use dependency injection, I think we should deprecate all 5 methods. The method container() is private, so should never be called outside of the class, but I think it's handy to deprecate anyway to not forget to remove it in the future.

Proposed resolution

Deprecate the following methods from \Drupal\feeds\Plugin\Type\PluginBase:

  • l()
  • url()
  • linkGenerator()
  • urlGenerator()
  • container()

And make sure that \Drupal\feeds\Feeds\Processor\EntityProcessorBase::entityValidate() is updated.

Code example:

@trigger_error(__METHOD__ . '() is deprecated in feeds:3.0.0-rc1 and is removed from feeds:4.0.0. There is no replacement. See https://www.drupal.org/node/xxx', E_USER_DEPRECATED);

'xxx' should be the node ID of the change record.

Remaining tasks

  • Draft a change record.
  • Deprecate the methods mentioned above.
  • Replace calls to the deprecated methods with something else.
  • Commit.
  • Publish the change record.

User interface changes

None.

API changes

From the class \Drupal\feeds\Plugin\Type\PluginBase, the methods l(), url(), linkGenerator(), urlGenerator() and container() will be deprecated.

Data model changes

None.

📌 Task
Status

Active

Version

3.0

Component

Code

Created by

🇳🇱Netherlands MegaChriz

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

Comments & Activities

Production build 0.71.5 2024