Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions components/contracts.rst
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,28 @@ that can be enabled when using :ref:`autoconfiguration <services-autoconfigure>`
or manual :doc:`service tagging </service_container/tags>` (or any other means
provided by your framework.)

``ContainerAwareInterface``
~~~~~~~~~~~~~~~~~~~~~~~~~~~

.. versionadded:: 8.1

The ``ContainerAwareInterface`` was introduced in Symfony 8.1.

The :class:`Symfony\\Contracts\\Service\\ContainerAwareInterface` provides a
standard way for objects to expose their service container. It defines a single
method::

use Psr\Container\ContainerInterface;

interface ContainerAwareInterface
{
public function getContainer(): ContainerInterface;
}

In Symfony applications, the
:class:`Symfony\\Bundle\\FrameworkBundle\\Console\\Application` class implements
this interface, booting the kernel if needed before returning the container.

Design Principles
-----------------

Expand Down
Loading