Problem/Motivation

In src/Plugin/Condition/MobileDetectCondition.php file i am seeing class implementing ContainerFactoryPluginInterface but no service injection are added.If no service injection,then why using ContainerFactoryPluginInterface in the class

public function __construct(array $configuration, $plugin_id, array $plugin_definition) {
parent::__construct($configuration, $plugin_id, $plugin_definition);
}

/**
* {@inheritdoc}
*/
public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) {
return new static(
$configuration,
$plugin_id,
$plugin_definition
);
}

Proposed resolution

Remove use and implments ContainerFactoryPluginInterface

Comments

marcusvsouza created an issue. See original summary.

marcusvsouza’s picture

Status: Active » Needs review
StatusFileSize
new1.23 KB

Patch created.

guilhermevp’s picture

Status: Needs review » Needs work

Patch applies cleanly and work as intended, but while reviewing it I notice that since there is no new implementations related to the MobileDetectCondition class, you can remove create and __construct functions entirely for code cleanliness.

marcusvsouza’s picture

Status: Needs work » Needs review
StatusFileSize
new1.32 KB

Removed __construct function.

marcusvsouza’s picture

StatusFileSize
new1.29 KB

New patch with removed create and __construct functions.

guilhermevp’s picture

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

Hi Marcus! Thanks for the patch! It applies cleanly, but further testing revealed that we indeed need the create & construct classes for configuration purposes so we should move on with patch #2.

RTBC!

guilhermevp’s picture

Status: Reviewed & tested by the community » Fixed

Thanks Marcus!

Status: Fixed » Closed (fixed)

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