Dependency injection #4
No reviewers
Labels
No labels
Compat/Breaking
Kind/Bug
Kind/Documentation
Kind/Enhancement
Kind/Feature
Kind/Security
Kind/Testing
Priority
Critical
Priority
High
Priority
Low
Priority
Medium
Reviewed
Confirmed
Reviewed
Duplicate
Reviewed
Invalid
Reviewed
Won't Fix
Status
Abandoned
Status
Blocked
Status
Need More Info
No project
No assignees
1 participant
Notifications
Total time spent: 31 minutes
Due date
c.fahner
31 minutes
No due date set.
Dependencies
No dependencies set.
Reference
slendium/framework!4
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "issues/2"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Implements slendium/framework#2.
Adds the
InternalAssembler, which is the dependency injection implementation for this framework.WIP: Issue 2to WIP: 2 - Dependency injection@ -0,0 +13,4 @@* @copyright Slendium 2026*/#[Attribute(Attribute::TARGET_CLASS | Attribute::IS_REPEATABLE)]final readonly class ImplementedBy {Separate into
ImplementedBy(requires aclass-string) andMaybeImplementedBy(anystring) to make explicit which implementations MUST exist and which ones MAY be provided by other libraries.Alternatively, every module type could be annotated with a list of service interfaces mapped to their implementation types.
Pros:
UserServiceinterface could, for example, point toSlendium\Framework\Services\Users\UserServiceImpl, which would have to be added to the composer file of any implementing package.Cons:
The
ImplementedBymodel is a bit awkward in regards to namespacing, but constructs implementations on-demand.Going for the
ImplementedBymodel without the maybe-variant for now. It should be possible to provideDependencyResolver's from the configs, which will override anyImplementedByattribute.Additionally, the framework does not even have to provide a
UserServiceif it simply provides the ability to intercept requests. AnAuthmodule could be provided from the framework package itself which handles IP-address, origin and user validation. The defaultRequestInterceptorcould be markedImplementedByfor a class in this framework-provided module. If the module is inactive, this implementation won't be available and requests won't be intercepted. Using a customRequestInterceptorwould then require declaring an override using a resolver in the configs.@ -0,0 +10,4 @@interface DependencyResolver {/*** All dependent types satisfied by this resolver."An intersection of types satisfied by this resolver."
@ -0,0 +16,4 @@final readonly class SingletonResolver implements DependencyResolver {#[Override]public array $satisfies;Missing iterable value?
Edit: apparently this works on non-promoted properties only.
WIP: 2 - Dependency injectionto 2 - Dependency injection2 - Dependency injectionto Dependency injection