karser / KarserRecaptcha3Bundle

Google ReCAPTCHA v3 for Symfony
MIT License
160 stars 22 forks source link

Deprecated ref function in config to service #28

Closed RomanApunts closed 4 years ago

RomanApunts commented 4 years ago

Changes to config file to resolve deprecated function use "ref".

27

karser commented 4 years ago

This PR breaks builds other than symfony 5.1 https://travis-ci.org/github/karser/KarserRecaptcha3Bundle/builds/725195469 Can you please add a decorator that takes care of compatibility?

use Symfony\Component\DependencyInjection\Loader\Configurator\ReferenceConfigurator;

function getService(string $id): ReferenceConfigurator {
    if (function_exists('\Symfony\Component\DependencyInjection\Loader\Configurator\service')) {
        // >= sf 5.1 forward compatibility
        return \Symfony\Component\DependencyInjection\Loader\Configurator\service($id);
    }
    return \Symfony\Component\DependencyInjection\Loader\Configurator\ref($id);
}
RomanApunts commented 4 years ago

I am not sure how to apply the modifications that you indicate, if you would be so kind as to explain the steps to follow, because i see the changes a made break another time but now in all versions of Symfony.

karser commented 4 years ago

the error is Cannot redeclare getService(). Can you please try another name? getServiceOrRef or something like that

karser commented 4 years ago

Weird. I'll take a look at this.

karser commented 4 years ago

The previous error was because of services.php was injected multiple times. I removed the getService function because service/ref are one-liners. So I inlined their content for now. Tests pass. image

karser commented 4 years ago

@RomanApunts thank you for your PR!