Config: support for constants in arguments

Notice: This thread is very old.
RadekDvorak
Member | 11
+
0
-

Is there any chance support for constants (request #550) will be merged soon? Is there any technical issue? It works for me.

David Grudl
Nette Core | 7251
+
0
-

There are technical issues. You can use constants this way: ::constant(E_ALL)

RadekDvorak
Member | 11
+
0
-

Thanks. I noticed it is not possible to use that notation in paramaters neon section. Is there any other notation for that? The only way I could make it work was to add array_walk_recursive to \Nette\Config\Compiler::processParamaters:

<?php
	public function processParameters()
	{
		if (isset($this->config['parameters'])) {

			array_walk_recursive($this->config['parameters'], function(&$val) {
				if ($val instanceof \stdClass && isset($val->value) && $val->value === "::constant") {
					$val = constant($val->attributes[0]);
				}
			});

			$this->container->parameters = $this->config['parameters'];
		}
	}
?>

Is this approach acceptable? If so, I'd start working on a pull request