-
-
Notifications
You must be signed in to change notification settings - Fork 320
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
Concatenate strings in config #203
Comments
Is it possible to just do |
@diosmosis Nope :( because then there is no difference between simple strings and those that need processing. |
Another idea: could combine the injectable string functionality w/ the factory function, eg, |
Implementation of #203: string definitions
Implemented in #224 Yay! |
In config files we often need to concatenate strings, but by referencing other container entries (i.e. lazy concatenation).
For example:
Of course this example doesn't work because
DI\link(...)
is not a string (it's a reference to a container entry). The only solution for now would be to use a closure which is overly verbose:Solutions
String concatenation definition
We could add a new
string
definition which would concatenate all parameters (lazily):While it does look verbose, a PHP 5.6 example looks better:
String expression definition
We could have a
string
definition which allows to construct strings with expressions:Mix
We could also make
DI\string()
provide both behaviors. I don't like having a choice though, because it can be confusing, but maybe this can be an exception?Other containers
The text was updated successfully, but these errors were encountered: