2011-08-25 22:53:05 -05:00
|
|
|
<?php namespace Laravel;
|
|
|
|
|
|
2011-09-04 23:19:14 -05:00
|
|
|
abstract class Controller {
|
|
|
|
|
|
2011-08-25 22:53:05 -05:00
|
|
|
/**
|
|
|
|
|
* A stub method that will be called before every request to the controller.
|
|
|
|
|
*
|
2011-08-31 00:07:45 -05:00
|
|
|
* If a value is returned by the method, it will be halt the request cycle
|
2011-08-25 22:53:05 -05:00
|
|
|
* and will be considered the response to the request.
|
|
|
|
|
*
|
|
|
|
|
* @return mixed
|
|
|
|
|
*/
|
2011-08-26 21:42:04 -05:00
|
|
|
public function before() {}
|
|
|
|
|
|
2011-08-25 22:53:05 -05:00
|
|
|
/**
|
|
|
|
|
* Magic Method to handle calls to undefined functions on the controller.
|
2011-09-03 23:46:52 -05:00
|
|
|
*
|
|
|
|
|
* By default, the 404 response will be returned for an calls to undefined
|
|
|
|
|
* methods on the controller. However, this method may also be overridden
|
|
|
|
|
* and used as a pseudo-router by the controller.
|
2011-08-25 22:53:05 -05:00
|
|
|
*/
|
2011-09-03 23:46:52 -05:00
|
|
|
public function __call($method, $parameters)
|
|
|
|
|
{
|
2011-09-20 23:14:09 -05:00
|
|
|
return Response::error('404');
|
2011-09-03 23:46:52 -05:00
|
|
|
}
|
2011-08-25 22:53:05 -05:00
|
|
|
|
2011-09-06 22:04:52 -05:00
|
|
|
/**
|
2011-09-08 17:49:16 -05:00
|
|
|
* Dynamically resolve items from the application IoC container.
|
2011-09-09 20:55:24 -05:00
|
|
|
*
|
|
|
|
|
* First, "laravel." will be prefixed to the requested item to see if there is
|
|
|
|
|
* a matching Laravel core class in the IoC container. If there is not, we will
|
|
|
|
|
* check for the item in the container using the name as-is.
|
2011-09-06 22:04:52 -05:00
|
|
|
*/
|
|
|
|
|
public function __get($key)
|
|
|
|
|
{
|
2011-09-21 21:46:16 -05:00
|
|
|
if (IoC::container()->registered("laravel.{$key}"))
|
|
|
|
|
{
|
|
|
|
|
return IoC::container()->resolve("laravel.{$key}");
|
|
|
|
|
}
|
|
|
|
|
elseif (IoC::container()->registered($key))
|
2011-09-08 17:49:16 -05:00
|
|
|
{
|
2011-09-20 23:36:13 -05:00
|
|
|
return IoC::container()->resolve($key);
|
2011-09-08 17:49:16 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
throw new \Exception("Attempting to access undefined property [$key] on controller.");
|
2011-09-06 22:04:52 -05:00
|
|
|
}
|
|
|
|
|
|
2011-08-25 22:53:05 -05:00
|
|
|
}
|