swarrot / SwarrotBundle

A symfony bundle for swarrot integration
MIT License
89 stars 59 forks source link

Cast broker port configuration variable to int #142

Closed jdecool closed 5 years ago

jdecool commented 5 years ago

I've the same issue describe in #131 with environment variables, even if I use the int: cast with Symfony 3.4.

My configuration looks like :

swarrot:
    connections:
        rabbitmq:
            host: '%env(RABBITMQ_HOST)%'
            port: '%env(int:RABBITMQ_PORT)%'
            login: '%env(RABBITMQ_LOGIN)%'
            password: '%env(RABBITMQ_PASSWORD)%'
            vhost: '/'

The DSN solution is not tagged yet. So to keep compatibility with existing configuration, I had a normalisation of the port variable in the dependency configuration.

odolbeau commented 5 years ago

That's strange! :/

Thanks anyway for this bugfix. :)

jdecool commented 5 years ago

👍

Is it possible to tag a new version ?

There some features that available in the master branch, but not usable because the latest tag is too old.

odolbeau commented 5 years ago

Yep, it's done. :)

jdecool commented 5 years ago

Thanks !

odolbeau commented 5 years ago

Hi @jdecool. Does this solve your problem correctly? It looks like there a BC break for some users (see #143 )

jdecool commented 5 years ago

I've tested, it introduce an BC break. Sorry for that.

We can try a fix with something like :

->integerNode('port')
    ->beforeNormalization()
        ->ifString()
        ->then(function(string $port) {
                if (is_numeric($port)) {
                    return (int) $port;
                }

                return $port;
            })
        ->end()
    ->defaultValue(5672)
    ->end()
->end()
odolbeau commented 5 years ago

@matthieuwerner doest it solve your problem?