public function setSingleton($class, $definition = [], array $params = [])
    {
        $normalizedDefinition = $this->normalizeDefinition($class, $definition);

        if (is_array($normalizedDefinition)) {
            $concrete = $normalizedDefinition['class'];
        } else {
            $concrete = $class;
        }

        if ($class !== $concrete) {
            $this->alias($concrete, $class);
        }

        $this->_definitions[$concrete] = $normalizedDefinition;
        $this->_params[$concrete] = $params;
        $this->_singletons[$concrete] = null;

        return $this;
    }
public function setSingleton($class, $definition = [], array $params = [])
    {
        $normalizedDefinition = $this->normalizeDefinition($class, $definition);

        if (is_array($normalizedDefinition)) {
            $concrete = $normalizedDefinition['class'];
        } else {
            $concrete = $class;
        }

        if ($class !== $concrete) {
            $this->alias($concrete, $class);
        }

        $this->_definitions[$concrete] = $normalizedDefinition;
        $this->_params[$concrete] = $params;
        $this->_singletons[$concrete] = null;

        return $this;
    }
public function setSingleton ( $ class , $ definition = [ ] , array $ params = [ ] ) { $ normalizedDefinition = $ this -> normalizeDefinition ( $ class , $ definition ) ; if ( is_array ( $ normalizedDefinition ) ) { $ concrete = $ normalizedDefinition [ 'class' ] ; } else { $ concrete = $ class ; } if ( $ class !== $ concrete ) { $ this -> alias ( $ concrete , $ class ) ; } $ this -> _definitions [ $ concrete ] = $ normalizedDefinition ; $ this -> _params [ $ concrete ] = $ params ; $ this -> _singletons [ $ concrete ] = null ; return $ this ; }
Registers a class definition with this container and marks the class as a singleton class.

This method is similar to [[set()]] except that classes registered via this method will only have one
instance. Each time [[get()]] is called, the same instance of the specified class will be returned.

@param string $class class name, interface name or alias name
@param mixed $definition the definition associated with `$class`. See [[set()]] for more details.
@param array $params the list of constructor parameters. The parameters will be passed to the class
constructor when [[get()]] is called.
@return static the container itself
@see set()
Registers a class definition with this container and marks the class as a singleton class .