Skip to main content
2 of 2
improved formatting
avpaderno
  • 97.9k
  • 15
  • 164
  • 284

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

Sometimes I encounter a public static function create() in plugin classes, for the example in the code show in Tutorial on Using Drupal 8 Plugin Derivatives Effectively.

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

Could you clarify me what the purpose of that function is, for example what it should do and where it's used?

Yakimkin Roman
  • 948
  • 1
  • 11
  • 26