function DbtngExampleAddForm::create

We'll use the ContainerInjectionInterface pattern here to inject the current user and also get the string_translation service.

File

modules/dbtng_example/src/Form/DbtngExampleAddForm.php, line 46

Class

DbtngExampleAddForm
Form to add a database entry, with all the interesting fields.

Namespace

Drupal\dbtng_example\Form

Code

public static function create(ContainerInterface $container) {
  $form = new static($container->get('dbtng_example.repository'), $container->get('current_user'));
  // The StringTranslationTrait trait manages the string translation service
  // for us. We can inject the service here.
  $form->setStringTranslation($container->get('string_translation'));
  $form->setMessenger($container->get('messenger'));
  return $form;
}