Problem/Motivation

The method getPlugins in the Lazy Service is defined as static, but is called from the Service Object in the LazyForm, rather than the Lazy namespace.

$plugins = array_keys($this->lazyLoad::getPlugins());

Proposed resolution

It should be rather be defined not static, as Drupal 8 OOP best practice, and called appropriatley in the LazyForm, such as:

$plugins = array_keys($this->lazyLoad->getPlugins());

or called just from the Lazy namespace such as Lazy::getPlugins()),
but in this case it would make it incoherent the use of the Lazy service in the LazyForm and compromise the Unit testability of the 'buildForm' method (bad practice to inject static methods in not static ones)

Comments

itamair created an issue. See original summary.

itamair’s picture

Issue summary: View changes
itamair’s picture

Status: Active » Needs review
StatusFileSize
new1.25 KB

The attached patch implements the approach that would personally prefer and I feel to suggest ...

Status: Needs review » Needs work

The last submitted patch, 3: lazy_getPlugins_not_static_3212078_#3.patch, failed testing. View results

  • osman committed f5432d4 on 8.x-3.x
    Issue #3212078 by itamair: Static method getPlugins() should be not...
osman’s picture

Status: Needs work » Fixed

Thanks for the patch italo

Status: Fixed » Closed (fixed)

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