public function setShared($name, $definition)
    {
        if (isset($this->_instances[$name])) {
            throw new MisuseException(['it\'s too late to setShared(): `:name` instance has been created', 'name' => $name]);
        }

        if (is_string($definition)) {
            if (strpos($definition, '/') !== false || preg_match('#^[\w\\\\]+$#', $definition) !== 1) {
                $definition = ['class' => $this->_interClassName($name), $definition];
            } elseif (strpos($definition, '\\') === false) {
                $definition = $this->_completeClassName($name, $definition);
            }
        } elseif (is_array($definition)) {
            if (isset($definition['class'])) {
                if (strpos($definition['class'], '\\') === false) {
                    $definition['class'] = $this->_completeClassName($name, $definition['class']);
                }
            } elseif (isset($definition[0]) && count($definition) !== 1) {
                if (strpos($definition[0], '\\') === false) {
                    $definition[0] = $this->_completeClassName($name, $definition[0]);
                }
            } else {
                $definition['class'] = $this->_interClassName($name);
            }
        } elseif (is_object($definition)) {
            $definition = ['class' => $definition];
        } else {
            throw new UnexpectedValueException(['`:definition` definition is unknown', 'definition' => $name]);
        }

        $this->_definitions[$name] = $definition;

        return $this;
    }
public function setShared($name, $definition)
    {
        if (isset($this->_instances[$name])) {
            throw new MisuseException(['it\'s too late to setShared(): `:name` instance has been created', 'name' => $name]);
        }

        if (is_string($definition)) {
            if (strpos($definition, '/') !== false || preg_match('#^[\w\\\\]+$#', $definition) !== 1) {
                $definition = ['class' => $this->_interClassName($name), $definition];
            } elseif (strpos($definition, '\\') === false) {
                $definition = $this->_completeClassName($name, $definition);
            }
        } elseif (is_array($definition)) {
            if (isset($definition['class'])) {
                if (strpos($definition['class'], '\\') === false) {
                    $definition['class'] = $this->_completeClassName($name, $definition['class']);
                }
            } elseif (isset($definition[0]) && count($definition) !== 1) {
                if (strpos($definition[0], '\\') === false) {
                    $definition[0] = $this->_completeClassName($name, $definition[0]);
                }
            } else {
                $definition['class'] = $this->_interClassName($name);
            }
        } elseif (is_object($definition)) {
            $definition = ['class' => $definition];
        } else {
            throw new UnexpectedValueException(['`:definition` definition is unknown', 'definition' => $name]);
        }

        $this->_definitions[$name] = $definition;

        return $this;
    }
public function setShared ( $ name , $ definition ) { if ( isset ( $ this -> _instances [ $ name ] ) ) { throw new MisuseException ( [ 'it\'s too late to setShared(): `:name` instance has been created' , 'name' => $ name ] ) ; } if ( is_string ( $ definition ) ) { if ( strpos ( $ definition , '/' ) !== false || preg_match ( '#^[\w\\\\]+$#' , $ definition ) !== 1 ) { $ definition = [ 'class' => $ this -> _interClassName ( $ name ) , $ definition ] ; } elseif ( strpos ( $ definition , '\\' ) === false ) { $ definition = $ this -> _completeClassName ( $ name , $ definition ) ; } } elseif ( is_array ( $ definition ) ) { if ( isset ( $ definition [ 'class' ] ) ) { if ( strpos ( $ definition [ 'class' ] , '\\' ) === false ) { $ definition [ 'class' ] = $ this -> _completeClassName ( $ name , $ definition [ 'class' ] ) ; } } elseif ( isset ( $ definition [ 0 ] ) && count ( $ definition ) !== 1 ) { if ( strpos ( $ definition [ 0 ] , '\\' ) === false ) { $ definition [ 0 ] = $ this -> _completeClassName ( $ name , $ definition [ 0 ] ) ; } } else { $ definition [ 'class' ] = $ this -> _interClassName ( $ name ) ; } } elseif ( is_object ( $ definition ) ) { $ definition = [ 'class' => $ definition ] ; } else { throw new UnexpectedValueException ( [ '`:definition` definition is unknown' , 'definition' => $ name ] ) ; } $ this -> _definitions [ $ name ] = $ definition ; return $ this ; }
Registers an "always shared" component in the components container

@param string $name
@param mixed  $definition

@return static
Registers an always shared component in the components container