di.xml constant type vs init_parameter

Found it.
For const the value of the specified constant is used.
For init_parameter, the value provided must be a constant name but the actual value used is the value of $_SERVER[constant value here].

In the method Magento\Framework\ObjectManager\Factory\AbstractFactory::resolveArgument metohod you will find this

    else if ($argument === (array)$argument) {
        if (isset($argument['argument'])) {
            if (isset($this->globalArguments[$argument['argument']])) {
                $argument = $this->globalArguments[$argument['argument']];
            } else {
                $argument = $paramDefault;
            }
        } else if (!empty($argument)) {
            $this->parseArray($argument);
        }
    }

$argument['argument'] looks very similar to what the init parameter interpreter returns.
And if there is a value with the key $argument['argument'] in the globalArguments member that one is returned.
globalArguments member is populated with the arguments with which the bootstrap class is initialized.
So for the web application these arguments are $_SERVER. (see index.php).

Conclusion:

<argument name="appMode" xsi:type="init_parameter">Magento\Framework\App\State::PARAM_MODE</argument>

means that the parameter named appMode will have the value $_SERVER[Magento\Framework\App\State::PARAM_MODE] if it is set.
Which means $_SERVER['MAGE_MODE']

Tags:

Magento2

Di