src/View/Component/Manager.php
/**
	 * @param string $componentName
	 * @param array $constructorArgs
	 * @return string
	 *
	 * @throws InvalidArgumentException if the component cannot be found.
	 * @throws ViewException if the component encounters a render error.
	 */
@param string $componentName
@param array $constructorArgs
@return string

@throws InvalidArgumentException if the component cannot be found.
@throws ViewException if the component encounters a render error.
@param string $componentName @param array $constructorArgs @return string @throws InvalidArgumentException if the component cannot be found . @throws ViewException if the component encounters a render error .
public function compile($componentName, $constructorArgs = array()) {
		if (isset($this->currentlyCompiling[$componentName])) {
			throw new ViewException('Component compiler detected an infinite loop.');
		}
		$this->currentlyCompiling[$componentName] = true;
		$componentName = str_replace('\\', '/', $componentName);
		$viewName = '@component/' . $componentName;
		$absoluteFilePath = $this->getComponentPath($componentName);
		$component = $this->getComponent($absoluteFilePath);
		$object = $this->resolve($component['className'], $constructorArgs);
		$this->contents[$viewName] = $component['contents'];
		$context = Application::kernel()->view()->getContext();
		$context['this'] = $object;
		try {
			$template = new Template($viewName, $context);
			$return = $template->render();
			unset($this->currentlyCompiling[$componentName]);
			return $return;
		}
		catch (\Exception $e) {
			unset($this->currentlyCompiling[$componentName]);
			if ($e instanceof ViewException) throw $e;
			if ($e instanceof RuntimeError) throw $e;
			throw new ViewException(sprintf('%s in component: %s', basename(get_class($e)), $e->getMessage()));
		}
	}
public function compile ( $ componentName , $ constructorArgs = array ( ) ) { if ( isset ( $ this -> currentlyCompiling [ $ componentName ] ) ) { throw new ViewException ( 'Component compiler detected an infinite loop.' ) ; } $ this -> currentlyCompiling [ $ componentName ] = true ; $ componentName = str_replace ( '\\' , '/' , $ componentName ) ; $ viewName = '@component/' . $ componentName ; $ absoluteFilePath = $ this -> getComponentPath ( $ componentName ) ; $ component = $ this -> getComponent ( $ absoluteFilePath ) ; $ object = $ this -> resolve ( $ component [ 'className' ] , $ constructorArgs ) ; $ this -> contents [ $ viewName ] = $ component [ 'contents' ] ; $ context = Application :: kernel ( ) -> view ( ) -> getContext ( ) ; $ context [ 'this' ] = $ object ; try { $ template = new Template ( $ viewName , $ context ) ; $ return = $ template -> render ( ) ; unset ( $ this -> currentlyCompiling [ $ componentName ] ) ; return $ return ; } catch ( \ Exception $ e ) { unset ( $ this -> currentlyCompiling [ $ componentName ] ) ; if ( $ e instanceof ViewException ) throw $ e ; if ( $ e instanceof RuntimeError ) throw $ e ; throw new ViewException ( sprintf ( '%s in component: %s' , basename ( get_class ( $ e ) ) , $ e -> getMessage ( ) ) ) ; } }
@param string $componentName
 @param array $constructorArgs
 @return string
@param string $componentName @param array $constructorArgs @return string
// Resolve the dependency // Save data // Build the context // Compile