From 8ba0dfacc792420f215f728cc0b1d5120d85b53a Mon Sep 17 00:00:00 2001 From: Taylor Otwell Date: Sat, 8 Oct 2011 23:43:16 -0500 Subject: [PATCH] refactoring controller __get magic method ioc resolution. --- laravel/controller.php | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/laravel/controller.php b/laravel/controller.php index 8f966a68..ab3059d7 100644 --- a/laravel/controller.php +++ b/laravel/controller.php @@ -90,20 +90,17 @@ abstract class Controller { /** * Dynamically resolve items from the application IoC container. * - * 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. + * + * // Retrieve an object registered in the container as "mailer" + * $mailer = $this->mailer; + * + * // Equivalent call using the IoC container instance + * $mailer = IoC::container()->resolve('mailer'); + * */ public function __get($key) { - if (IoC::container()->registered("laravel.{$key}")) - { - return IoC::container()->core($key); - } - elseif (IoC::container()->registered($key)) - { - return IoC::container()->resolve($key); - } + if (IoC::container()->registered($key)) return IoC::container()->resolve($key); throw new \Exception("Attempting to access undefined property [$key] on controller."); }