Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update service definition for autowiring #55

Merged
merged 1 commit into from
Jun 12, 2017

Conversation

brianfreytag
Copy link
Contributor

As of Symfony 3.3, autowire_types is deprecated.

This adds an alias for the knpu.oauth2.registry service definition.

As of Symfony 3.3, autowire_types is deprecated.

This adds an alias for the knpu.oauth2.registry service definition.
@brianfreytag
Copy link
Contributor Author

When attempting to autowire the client registry:

azure.client_fetcher:
    class: AppBundle\Azure\Client\ClientFetcher
    autowire: true
use KnpU\OAuth2ClientBundle\Client\ClientRegistry;

class ClientFetcher
{
    /** @var ClientRegistry */
    private $clientRegistry;

    /**
     * @param ClientRegistry $clientRegistry
     */
    public function __construct(ClientRegistry $clientRegistry)
    {
        $this->clientRegistry = $clientRegistry;
    }
    ...
}

I received:

Autowiring services based on the types they implement is deprecated since Symfony 3.3 
and won't be supported in version 4.0. You should rename (or alias) the "knpu.oauth2.registry" service 
to "KnpU\OAuth2ClientBundle\Client\ClientRegistry" instead.

I fixed this based on the upgrade path here:

https://github.com/symfony/symfony/blob/master/UPGRADE-3.3.md#dependencyinjection

@brianfreytag
Copy link
Contributor Author

@weaverryan failure is false (hhvm)

@@ -13,6 +13,9 @@
<argument type="service" id="service_container" />
<argument /> <!-- argument added dynamically -->
</service>

<!-- Add service alias for autowiring -->
<service id="KnpU\OAuth2ClientBundle\Client\ClientRegistry" alias="knpu.oauth2.registry" public="false" />
Copy link
Member

@bocharsky-bw bocharsky-bw Jun 8, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't we rename knpu.oauth2.registry to KnpU\OAuth2ClientBundle\Client\ClientRegistry and do the reverse?

<service id="knpu.oauth2.registry" alias="KnpU\OAuth2ClientBundle\Client\ClientRegistry" public="false" />

I think this will fix the error you mentioned

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Per the official 3.3 UPGRADE documentation, they recommend they do it the way I have it in the PR.

<service id="annotations.reader" class="Doctrine\Common\Annotations\AnnotationReader" public="false" />
<service id="Doctrine\Common\Annotations\Reader" alias="annotations.reader" public="false" />

@weaverryan weaverryan merged commit 22963a9 into knpuniversity:master Jun 12, 2017
@weaverryan
Copy link
Member

Thanks @brianfreytag! I've just tagged 1.10.0 :)

@brianfreytag brianfreytag deleted the v3_3_deprecations branch June 12, 2017 20:13
@brianfreytag
Copy link
Contributor Author

Thank you @weaverryan

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants