src/Mouf/MoufManager.php
public function declareComponent($instanceName, $className, $external = false, $mode = self::DECLARE_ON_EXIST_EXCEPTION, $weak = false) {
		if (isset($this->declaredInstances[$instanceName])) {
			if ($mode == self::DECLARE_ON_EXIST_EXCEPTION) {
				throw new MoufException("Unable to create Mouf instance named '".$instanceName."'. An instance with this name already exists.");
			} elseif ($mode == self::DECLARE_ON_EXIST_KEEP_INCOMING_LINKS) {
				$this->declaredInstances[$instanceName]["fieldProperties"] = array();
				$this->declaredInstances[$instanceName]["setterProperties"] = array();
				$this->declaredInstances[$instanceName]["fieldBinds"] = array();
				$this->declaredInstances[$instanceName]["setterBinds"] = array();
				$this->declaredInstances[$instanceName]["weak"] = $weak;
				$this->declaredInstances[$instanceName]["comment"] = "";
			} elseif ($mode == self::DECLARE_ON_EXIST_KEEP_ALL) {
				// Do nothing
			}
		}
		
		if (strpos($className, '\\' === 0)) {
			$className = substr($className, 1);
		}
		
		$this->declaredInstances[$instanceName]["class"] = $className;
		$this->declaredInstances[$instanceName]["external"] = $external;
	}
public function declareComponent($instanceName, $className, $external = false, $mode = self::DECLARE_ON_EXIST_EXCEPTION, $weak = false) {
		if (isset($this->declaredInstances[$instanceName])) {
			if ($mode == self::DECLARE_ON_EXIST_EXCEPTION) {
				throw new MoufException("Unable to create Mouf instance named '".$instanceName."'. An instance with this name already exists.");
			} elseif ($mode == self::DECLARE_ON_EXIST_KEEP_INCOMING_LINKS) {
				$this->declaredInstances[$instanceName]["fieldProperties"] = array();
				$this->declaredInstances[$instanceName]["setterProperties"] = array();
				$this->declaredInstances[$instanceName]["fieldBinds"] = array();
				$this->declaredInstances[$instanceName]["setterBinds"] = array();
				$this->declaredInstances[$instanceName]["weak"] = $weak;
				$this->declaredInstances[$instanceName]["comment"] = "";
			} elseif ($mode == self::DECLARE_ON_EXIST_KEEP_ALL) {
				// Do nothing
			}
		}
		
		if (strpos($className, '\\' === 0)) {
			$className = substr($className, 1);
		}
		
		$this->declaredInstances[$instanceName]["class"] = $className;
		$this->declaredInstances[$instanceName]["external"] = $external;
	}
public function declareComponent ( $ instanceName , $ className , $ external = false , $ mode = self :: DECLARE_ON_EXIST_EXCEPTION , $ weak = false ) { if ( isset ( $ this -> declaredInstances [ $ instanceName ] ) ) { if ( $ mode == self :: DECLARE_ON_EXIST_EXCEPTION ) { throw new MoufException ( "Unable to create Mouf instance named '" . $ instanceName . "'. An instance with this name already exists." ) ; } elseif ( $ mode == self :: DECLARE_ON_EXIST_KEEP_INCOMING_LINKS ) { $ this -> declaredInstances [ $ instanceName ] [ "fieldProperties" ] = array ( ) ; $ this -> declaredInstances [ $ instanceName ] [ "setterProperties" ] = array ( ) ; $ this -> declaredInstances [ $ instanceName ] [ "fieldBinds" ] = array ( ) ; $ this -> declaredInstances [ $ instanceName ] [ "setterBinds" ] = array ( ) ; $ this -> declaredInstances [ $ instanceName ] [ "weak" ] = $ weak ; $ this -> declaredInstances [ $ instanceName ] [ "comment" ] = "" ; } elseif ( $ mode == self :: DECLARE_ON_EXIST_KEEP_ALL ) { // Do nothing
 } } if ( strpos ( $ className , '\\' === 0 ) ) { $ className = substr ( $ className , 1 ) ; } $ this -> declaredInstances [ $ instanceName ] [ "class" ] = $ className ; $ this -> declaredInstances [ $ instanceName ] [ "external" ] = $ external ; }
Declares a new component.

@param string $instanceName
@param string $className
@param boolean $external Whether the component is external or not. Defaults to false.
@param int $mode Depending on the mode, the behaviour will be different if an instance with the same name already exists.
@param bool $weak If the object is weak, it will be destroyed if it is no longer referenced.
Declares a new component .