You are here

public static function EntityAutocomplete::create in Examples for Developers 3.x

Same name and namespace in other branches
  1. 8 ajax_example/src/Form/EntityAutocomplete.php \Drupal\ajax_example\Form\EntityAutocomplete::create()

Container injection factory.

Parameters

\Symfony\Component\DependencyInjection\ContainerInterface $container: The service discovery container.

Return value

self The form object.

Overrides ContainerInjectionInterface::create

File

modules/ajax_example/src/Form/EntityAutocomplete.php, line 41

Class

EntityAutocomplete
A simple autocomplete form which looks up usernames.

Namespace

Drupal\ajax_example\Form

Code

public static function create(ContainerInterface $container) {
  $form = new static($container
    ->get('entity_type.manager'));
  $form
    ->setStringTranslation($container
    ->get('string_translation'));
  $form
    ->setMessenger($container
    ->get('messenger'));
  return $form;
}