-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Issue #2504025 by Fabianx, Pol: Add static container factory method for plugins (D8 style) #72
Issue #2504025 by Fabianx, Pol: Add static container factory method for plugins (D8 style) #72
Conversation
$plugin_class = static::getPluginClass($plugin_id, $plugin_definition); | ||
|
||
// If the plugin provides a factory method, pass the container to it. | ||
if (is_subclass_of($plugin_class, 'Drupal\service_container\Plugin\ContainerAwarePluginManager')) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This needs to be the Interface that I outlined, not our own.
We are okay to add that interface, too.
Investigating... There were 2 errors:
|
* @inheritdoc | ||
*/ | ||
public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) { | ||
return 'Hello World!'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, that is wrong.
This needs to be:
return new static($configuration, $plugin_id, $plugin_definition, 'Hello World');
then add a __construct here, that populates $this->data and add a getData() method.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, I wrote that because I didn't know how to test it correctly.
RTBM |
Just waiting for tests and coverage report. |
…ntainerAwarePluginManager Issue #2504025 by Fabianx, Pol: Add static container factory method for plugins (D8 style)
No description provided.