<?php
namespace Concrete\Core\Routing;
use Response;
use Request;
class ClosureRouteCallback extends RouteCallback {

	public function execute(Request $request, \Concrete\Core\Routing\Route $route, $parameters) {
		$r = new Response();
		$r->setContent($this->callback->__invoke());
		return $r;
	}

	public function __sleep() {
		unset($this->callback);
	}

	public static function getRouteAttributes($callback) {
		$callback = new static($callback);
		return array('callback' => $callback);
	}


}

<?php
namespace Concrete\Core\Routing;
use Symfony\Component\HttpKernel;
use Response;
use Request;

class ClosureRouteCallback extends RouteCallback {

	public function execute(Request $request, \Concrete\Core\Routing\Route $route, $parameters) {
		$resolver = new HttpKernel\Controller\ControllerResolver();
		$arguments = $resolver->getArguments($request, $this->callback);
		$r = new Response();
		$r->setContent(call_user_func_array($this->callback, $arguments));
		return $r;
	}

	public function __sleep() {
		unset($this->callback);
	}

	public static function getRouteAttributes($callback) {
		$callback = new static($callback);
		return array('callback' => $callback);
	}


}

Add Parameters to Route Closures
Add Parameters to Route Closures

Use 'HttpKernel\Controller\ControllerResolver::getArguments' to get the
parameter arguments mapped properly to the closure function arguments

Function arguments must have the same name as the route parameters but
can be in any order.


Former-commit-id: 3130338c54a8956299a333ce34c0e077fe2b7690