<commit_before><?php namespace Laravel\Routing;

use Laravel\IoC;
use Laravel\Response;

abstract class Controller {

	/**
	 * The "before" filters defined for the controller.
	 *
	 * @var array
	 */
	public $before = array();

	/**
	 * The "after" filters defined for the controller.
	 *
	 * @var array
	 */
	public $after = array();

	/**
	 * Handle the delegation of a route to a controller method.
	 *
	 * The controller destination should follow a {controller}@{method} convention.
	 * Nested controllers may be delegated to using dot syntax.
	 *
	 * For example, a destination of "user.profile@show" would call the User_Profile
	 * controller's show method with the given parameters.
	 *
	 * @param  string  $destination
	 * @param  array   $parameters
	 * @return mixed
	 */
	public static function call($destination, $parameters = array())
	{
		if (strpos($destination, '@') === false)
		{
			throw new \Exception("Route delegate [{$destination}] has an invalid format.");
		}

		list($controller, $method) = explode('@', $destination);

		$controller = static::resolve($controller);

		if (is_null($controller) or static::hidden($method))
		{
			return Response::error('404');
		}

		// Again, as was the case with route closures, if the controller
		// "before" filters return a response, it will be considered the
		// response to the request and the controller method will not be
		// used to handle the request to the application.
		$response = Filter::run($controller->filters('before'), array(), true);

		if (is_null($response))
		{
			$response = call_user_func_array(array($controller, $method), $parameters);
		}

		// The after filter and the framework expects all responses to
		// be instances of the Response class. If the route did not
		// return an instsance of Response, we will make on now.
		if ( ! $response instanceof Response) $response = new Response($response);

		$filters = array_merge($this->filters('after'), array('after'));

		Filter::run($filters, array($response));

		return $response;
	}

	/**
	 * Resolve a controller name to a controller instance.
	 *
	 * @param  Container   $container
	 * @param  string      $controller
	 * @return Controller
	 */
	public static function resolve($controller)
	{
		if ( ! static::load($controller)) return;

		// If the controller is registered in the IoC container, we will
		// resolve it out of the container. Using constructor injection
		// on controllers via the container allows more flexible and
		// testable development of applications.
		if (IoC::container()->registered('controllers.'.$controller))
		{
			return IoC::container()->resolve('controllers.'.$controller);
		}<commit_msg>fixed controller routing bug.<commit_after><?php namespace Laravel\Routing;

use Laravel\IoC;
use Laravel\Response;

abstract class Controller {

	/**
	 * The "before" filters defined for the controller.
	 *
	 * @var array
	 */
	public $before = array();

	/**
	 * The "after" filters defined for the controller.
	 *
	 * @var array
	 */
	public $after = array();

	/**
	 * Handle the delegation of a route to a controller method.
	 *
	 * The controller destination should follow a {controller}@{method} convention.
	 * Nested controllers may be delegated to using dot syntax.
	 *
	 * For example, a destination of "user.profile@show" would call the User_Profile
	 * controller's show method with the given parameters.
	 *
	 * @param  string  $destination
	 * @param  array   $parameters
	 * @return mixed
	 */
	public static function call($destination, $parameters = array())
	{
		if (strpos($destination, '@') === false)
		{
			throw new \Exception("Route delegate [{$destination}] has an invalid format.");
		}

		list($controller, $method) = explode('@', $destination);

		$controller = static::resolve($controller);

		if (is_null($controller) or static::hidden($method))
		{
			return Response::error('404');
		}

		// Again, as was the case with route closures, if the controller
		// "before" filters return a response, it will be considered the
		// response to the request and the controller method will not be
		// used to handle the request to the application.
		$response = Filter::run($controller->filters('before'), array(), true);

		if (is_null($response))
		{
			$response = call_user_func_array(array($controller, $method), $parameters);
		}

		// The after filter and the framework expects all responses to
		// be instances of the Response class. If the route did not
		// return an instsance of Response, we will make on now.
		if ( ! $response instanceof Response) $response = new Response($response);

		$filters = array_merge($controller->filters('after'), array('after'));

		Filter::run($filters, array($response));

		return $response;
	}

	/**
	 * Resolve a controller name to a controller instance.
	 *
	 * @param  Container   $container
	 * @param  string      $controller
	 * @return Controller
	 */
	public static function resolve($controller)
	{
		if ( ! static::load($controller)) return;

		// If the controller is registered in the IoC container, we will
		// resolve it out of the container. Using constructor injection
		// on controllers via the container allows more flexible and
		// testable development of applications.
		if (IoC::container()->registered('controllers.'.$controller))
		{
			return IoC::container()->resolve('controllers.'.$controller);
		}
{'fraction_non_alphanumeric': 0.12258184523809523, 'fraction_numerical': 0.0011160714285714285, 'mean_word_length': 3.7710736468500445, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, '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': '5604700', 'n_tokens_mistral': 1579, 'n_tokens_neox': 1406, 'n_words': 545}