Skip to main content
1 of 2
Yakimkin Roman
  • 948
  • 1
  • 11
  • 26

What is public static function create() in plugins for?

Sometimes I encounter a function public static function create with arguments in plugin classes.

For example, here https://www.sitepoint.com/tutorial-on-using-drupal-8-plugin-derivatives-effectively/ we can see it.

public static function create(ContainerInterface $container, $base_plugin_id) {
    return new static(
      $container->get('entity.manager')->getStorage('node')
    );
  }

Could you clarify me, what is the function for? What should it do and where is it used?

Yakimkin Roman
  • 948
  • 1
  • 11
  • 26