Location: PHPKode > projects > GnomePHP > peec-GnomePHP-b5a360b/gnomephp/mvc/router/BackendObject.php
<?php
namespace gnomephp\mvc\router;

/**
 * This object will get returned if a route matches a request.
 * 
 * @author peec
 *
 */
class BackendObject{
	private $controller='';
	private $method='';
	private $arguments=array();
	
	
	private $baseNamespace = null;
	
	/**
	 * 
	 * @param string $controller The controller name, can also contain a full namespace.
	 * @param string $method The methods name
	 * @param array $arguments Array of arguments passed into the method.
	 */
	public function __construct($controller, $method, $arguments=array()){
		$this->controller = $controller;
		$this->method = $method;
		$this->arguments = $arguments;
	}
	
	
	/**
	 * Sets the base namespace to use.
	 * Forexample \myapp\controller.
	 * 
	 * @param string $ns Base namespace of the controller. Forexample: \myapp\controller , getController will then return \myapp\controller\TheControllerClass
	 */
	public function setBaseNamespace($ns){
		$this->baseNamespace = $ns;
	}
	
	/**
	 * Returns true if we detect a namespace in the controller name.
	 */
	public function hasNamespace(){
		return strstr($this->controller, '\\');
	}
	
	/**
	 * Gets the controller.
	 * If a namespace is present, this will get applied to the controller.
	 */
	public function getController(){

		return ($this->baseNamespace !== null  &&  substr($this->controller, 0, 1) != '\\' ? $this->baseNamespace.'\\' : '') . $this->controller;
	}
	
	/**
	 * Gets the method.
	 */
	public function getMethod(){
		return $this->method;
	}
	
	/**
	 * Gets the arguments
	 */
	public function getArguments(){
		return $this->arguments;
	}
	
	
	/**
	 * Returns a unique md5 string based on all the object variables.
	 * @return String md5 String unique to this object.
	 */
	public function __toString(){
		return md5($this->controller . $this->baseNamespace . $this->method . var_export($this->arguments, true));
	}
	
	
	
	
	
}
Return current item: GnomePHP