I know this is probably not possible, but is there a clean way to use a PHP class constant within a YAML config/services/etc. file for Symfony2?
For example, if I ha
It should be possible to insert argument as plain 'text' in config and inside class __construct($constant1)
then request constant through variable by constant($constant1)
function.
But I am not sure about global constants here, because they may not be defined at time of using, but it shouldn't be a problem for class constants with whole namespace, because namespace locator is already defined at moment of calling the class.
Example config:
services:
my_service:
class: Some\Class
arguments:
- 'My\Bundle\DependencyInjection\MyClass::MY_CONST'
and example class method:
public function __construct($arg1)
{
$myRequiredConstantValue = constant($arg1);
}