<commit_before><?php
/**
 * @package  Framework\Request
 * @version  0.1.0
 * @author  <NAME> (<EMAIL>)
 * @copyright  Copyright 2010 <NAME> (<a href="http://www.mitmaro.ca">www.mitmaro.ca</a>)
 * @license  <a href="http://www.opensource.org/licenses/mit-license.php">The MIT License</a>
 * @dependencies
 * <ul>
 *     <li>\Framework\Controller</li>
 *     <li>\Framework\Session (Optional)</li>
 * </ul>
 */

namespace Framework\Request;

use
	\Framework\Session\Session,
	\Framework\View\View
;

class Request {

	/**
	 * An associative array of parameters
	 * @var array
	 */
	protected $params = array();
	
	/**
	 * An associative array of url mappers in the format (pattern => callback)
	 */
	protected $url_maps = array();
	
	/**
	 * Handle a request
	 *
	 * @param string $url (Optional) The request URL, set to override the auto dectection
	 */
	public function beginRequest($url = null) {
		$callback = $this->resolveUrl($url);
		$this->setParams();
		
		if (class_exists('\Framework\Session')) {
			$this->setReferrer($url);
		}
		
		// if a controller object was passed in, use it directly
		if (is_object($callback['handler']['class'])) {
			$class = $callback['handler']['class'];
			$view = $class->getView();
		}
		else {
			$class_name = $callback['handler']['class'];
			$view = new View();
			$class = new $class_name($this, $view);
		}
		
		$method_name = $callback['handler']['method'];
		
		// create the controller, and run
		$class->_preInit();
		$class->_init();
		$class->_postInit();
		$class->_preAction();
		call_user_func_array(array($class, $method_name), $callback['params']);
		$class->_postAction();<commit_msg>Fixed broken reference to the Session class<commit_after><?php
/**
 * @package  Framework\Request
 * @version  0.1.0
 * @author  <NAME> (<EMAIL>)
 * @copyright  Copyright 2010 <NAME> (<a href="http://www.mitmaro.ca">www.mitmaro.ca</a>)
 * @license  <a href="http://www.opensource.org/licenses/mit-license.php">The MIT License</a>
 * @dependencies
 * <ul>
 *     <li>\Framework\Controller</li>
 *     <li>\Framework\Session (Optional)</li>
 * </ul>
 */

namespace Framework\Request;

use
	\Framework\Session\Session,
	\Framework\View\View
;

class Request {

	/**
	 * An associative array of parameters
	 * @var array
	 */
	protected $params = array();
	
	/**
	 * An associative array of url mappers in the format (pattern => callback)
	 */
	protected $url_maps = array();
	
	/**
	 * Handle a request
	 *
	 * @param string $url (Optional) The request URL, set to override the auto dectection
	 */
	public function beginRequest($url = null) {
		$callback = $this->resolveUrl($url);
		$this->setParams();
		
		if (class_exists('\Framework\Session\Session')) {
			$this->setReferrer($url);
		}
		
		// if a controller object was passed in, use it directly
		if (is_object($callback['handler']['class'])) {
			$class = $callback['handler']['class'];
			$view = $class->getView();
		}
		else {
			$class_name = $callback['handler']['class'];
			$view = new View();
			$class = new $class_name($this, $view);
		}
		
		$method_name = $callback['handler']['method'];
		
		// create the controller, and run
		$class->_preInit();
		$class->_init();
		$class->_postInit();
		$class->_preAction();
		call_user_func_array(array($class, $method_name), $callback['params']);
		$class->_postAction();
{'fraction_non_alphanumeric': 0.18419471153846154, 'fraction_numerical': 0.004206730769230769, 'mean_word_length': 3.755714285714286, 'pattern_counts': {'":': 0, '<': 31, '<?xml version=': 0, '>': 49, 'https://': 0, 'lorem ipsum': 0, 'www.': 6, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3931548', 'n_tokens_mistral': 1183, 'n_tokens_neox': 1056, 'n_words': 251}