src/ChickenWire/Controller.php
protected function _finish()
		{

			// Check layout path
			$layoutPath = !is_null($this->request->route->module) ? $this->request->route->module->path . '/Layouts' : LAYOUT_PATH;

			// Layout set?
			if (!isset($this->_layout)) {

				// Layout in controller?
				if (!is_null(static::$layout)) {

					// Use that.
					$this->_layout = $layoutPath . '/' . static::$layout;

				} elseif (!is_null($this->request->route->module) && !is_null($this->request->route->module->defaultLayout)) {

					// Use that with module info
					$this->_layout = $layoutPath . '/' . $this->request->route->module->defaultLayout;
					

				} else {

					// Use app's default.
					$this->_layout = LAYOUT_PATH . '/' . Application::getConfiguration()->defaultLayout;

				}

			}

			// No layout?
			if ($this->_layout === false) {

				// Just output the content then.
				if (array_key_exists('main', $this->_renderedContent)) {
					echo $this->_renderedContent['main'];
				}

			} else {

				// Guess the extension
				$layoutFile = $this->_guessExtension($this->_layout);
				
				// Not found?
				if ($layoutFile === false) {
					throw new \Exception("Couldn't find layout for " . $this->_layout, 1);					
				}
				$this->_layout = $layoutFile;

				// Create and render the layout
				$layout = new Layout($this->_layout, $this, $this->_renderedContent);

			}


		}
protected function _finish()
		{

			// Check layout path
			$layoutPath = !is_null($this->request->route->module) ? $this->request->route->module->path . '/Layouts' : LAYOUT_PATH;

			// Layout set?
			if (!isset($this->_layout)) {

				// Layout in controller?
				if (!is_null(static::$layout)) {

					// Use that.
					$this->_layout = $layoutPath . '/' . static::$layout;

				} elseif (!is_null($this->request->route->module) && !is_null($this->request->route->module->defaultLayout)) {

					// Use that with module info
					$this->_layout = $layoutPath . '/' . $this->request->route->module->defaultLayout;
					

				} else {

					// Use app's default.
					$this->_layout = LAYOUT_PATH . '/' . Application::getConfiguration()->defaultLayout;

				}

			}

			// No layout?
			if ($this->_layout === false) {

				// Just output the content then.
				if (array_key_exists('main', $this->_renderedContent)) {
					echo $this->_renderedContent['main'];
				}

			} else {

				// Guess the extension
				$layoutFile = $this->_guessExtension($this->_layout);
				
				// Not found?
				if ($layoutFile === false) {
					throw new \Exception("Couldn't find layout for " . $this->_layout, 1);					
				}
				$this->_layout = $layoutFile;

				// Create and render the layout
				$layout = new Layout($this->_layout, $this, $this->_renderedContent);

			}


		}
protected function _finish ( ) { // Check layout path $ layoutPath = ! is_null ( $ this -> request -> route -> module ) ? $ this -> request -> route -> module -> path . '/Layouts' : LAYOUT_PATH ; // Layout set? if ( ! isset ( $ this -> _layout ) ) { // Layout in controller? if ( ! is_null ( static :: $ layout ) ) { // Use that. $ this -> _layout = $ layoutPath . '/' . static :: $ layout ; } elseif ( ! is_null ( $ this -> request -> route -> module ) && ! is_null ( $ this -> request -> route -> module -> defaultLayout ) ) { // Use that with module info $ this -> _layout = $ layoutPath . '/' . $ this -> request -> route -> module -> defaultLayout ; } else { // Use app's default. $ this -> _layout = LAYOUT_PATH . '/' . Application :: getConfiguration ( ) -> defaultLayout ; } } // No layout? if ( $ this -> _layout === false ) { // Just output the content then. if ( array_key_exists ( 'main' , $ this -> _renderedContent ) ) { echo $ this -> _renderedContent [ 'main' ] ; } } else { // Guess the extension $ layoutFile = $ this -> _guessExtension ( $ this -> _layout ) ; // Not found? if ( $ layoutFile === false ) { throw new \ Exception ( "Couldn't find layout for " . $ this -> _layout , 1 ) ; } $ this -> _layout = $ layoutFile ; // Create and render the layout $ layout = new Layout ( $ this -> _layout , $ this , $ this -> _renderedContent ) ; } }
When the action has completed, the finish method will
tie up loose ends

@return void
When the action has completed the finish method will tie up loose ends