Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[Lock] Renamed target for autowire #60349

Open
@lyrixx

Description

@lyrixx

Description

I have the following configuration

framework:
    lock:
        resources:
            shared:
                - 'redis://%redis_shared_host%:%redis_shared_port%'
            crawler:
                - 'redis://%redis_crawler_host%:%redis_crawler_port%'

And I just noticed the naming for the Target attribute:

I have no name! /app/server/backend bin/console debug:autowi lock

Autowirable Types
=================

 The following classes & interfaces can be used as type-hints when autowiring:
 (only showing classes/interfaces matching lock)
 
[...]

 Factory provides method to create locks.
 Symfony\Component\Lock\LockFactory $crawlerLockFactory - target:crawler.lock.factory - alias:lock.crawler.factory
 Symfony\Component\Lock\LockFactory $sharedLockFactory - target:shared.lock.factory - alias:lock.shared.factory

So I need to write the following code:

    public function __construct(
        #[Target('shared.lock.factory')]
        private readonly LockFactory $lockFactory,
    ) {

This is not optimal. I would prefer to write

    public function __construct(
        #[Target('shared')]
        private readonly LockFactory $lockFactory,
    ) {

I would be more in sync with the http client, and the workflow.

WDYT?

Example

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Good first issueIdeal for your first contribution! (some Symfony experience may be required)Lock

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions