Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 2 additions & 0 deletions docs/1-essentials/05-container.md
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,8 @@ final class RouteBindingInitializer implements DynamicInitializer
}
```

The container remembers the outcome of `canInitialize` for every class and tag, so it should only depend on those two arguments.

## Autowired dependencies

When you need to assign a default implementation to an interface without any specific instantiation steps, creating an initializer class for a single line of code might feel excessive.
Expand Down
3 changes: 3 additions & 0 deletions packages/container/src/DynamicInitializer.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@

interface DynamicInitializer
{
/**
* Determines whether this initializer can initialize the given class and tag. The outcome is remembered by the container, so it should only depend on the class and tag.
*/
public function canInitialize(ClassReflector $class, string|UnitEnum|null $tag): bool;

public function initialize(ClassReflector $class, string|UnitEnum|null $tag, Container $container): object;
Expand Down
Loading
Loading