8.5.x FormBase.php FormBase::container()
8.0.x FormBase.php FormBase::container()
8.1.x FormBase.php FormBase::container()
8.2.x FormBase.php FormBase::container()
8.3.x FormBase.php FormBase::container()
8.4.x FormBase.php FormBase::container()
8.6.x FormBase.php FormBase::container()

Returns the service container.

This method is marked private to prevent sub-classes from retrieving services from the container through it. Instead, \Drupal\Core\DependencyInjection\ContainerInjectionInterface should be used for injecting services.

Return value

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

File

core/lib/Drupal/Core/Form/FormBase.php, line 206

Class

FormBase
Provides a base class for forms.

Namespace

Drupal\Core\Form

Code

private function container() {
  return \Drupal::getContainer();
}