yii\di\Container::setSingletons PHP Method

setSingletons() public method

Registers class definitions as singletons within this container by calling Container::setSingleton
See also: setDefinitions() for allowed formats of $singletons parameter
See also: setSingleton() to know more about possible values of definitions
Since: 2.0.11
public setSingletons ( array $singletons )
$singletons array array of singleton definitions. See [[setDefinitions()]] for allowed formats of array.
    public function setSingletons(array $singletons)
    {
        foreach ($singletons as $class => $definition) {
            if (count($definition) === 2 && array_values($definition) === $definition) {
                $this->setSingleton($class, $definition[0], $definition[1]);
                continue;
            }
            $this->setSingleton($class, $definition);
        }
    }