added resolver class file.

This commit is contained in:
Taylor Otwell 2011-09-03 23:48:15 -05:00
parent cd395c2638
commit 9da2041051
3 changed files with 27 additions and 25 deletions

View File

@ -1,30 +1,5 @@
<?php namespace Laravel;
abstract class Resolver {
/**
* Magic Method for resolving classes out of the IoC container.
*
* This allows the derived class to provide access to all of the Laravel libraries
* registered in the container. Currently, this class is derived by the Application
* and Controller classes.
*/
public function __get($key)
{
if (IoC::container()->registered('laravel.'.$key))
{
return IoC::container()->resolve('laravel.'.$key);
}
elseif (IoC::container()->registered($key))
{
return IoC::container()->resolve($key);
}
throw new \Exception("Attempting to access undefined property [$key].");
}
}
class Application extends Resolver {
/**

View File

@ -35,6 +35,7 @@
// --------------------------------------------------------------
// Bootstrap the application instance.
// --------------------------------------------------------------
require SYS_PATH.'resolver'.EXT;
require SYS_PATH.'application'.EXT;
$application = new Application;

26
laravel/resolver.php Normal file
View File

@ -0,0 +1,26 @@
<?php namespace Laravel;
abstract class Resolver {
/**
* Magic Method for resolving classes out of the IoC container.
*
* This allows the derived class to provide access to all of the Laravel libraries
* registered in the container. Currently, this class is derived by the Application
* and Controller classes.
*/
public function __get($key)
{
if (IoC::container()->registered('laravel.'.$key))
{
return IoC::container()->resolve('laravel.'.$key);
}
elseif (IoC::container()->registered($key))
{
return IoC::container()->resolve($key);
}
throw new \Exception("Attempting to access undefined property [$key].");
}
}