Files
spa-api/laravel/application.php

37 lines
801 B
PHP
Raw Normal View History

2011-08-26 21:42:04 -05:00
<?php namespace Laravel;
2011-08-31 00:07:45 -05:00
abstract class Resolver {
2011-08-26 21:42:04 -05:00
/**
2011-08-31 00:07:45 -05:00
* Magic Method for resolving classes out of the IoC container.
2011-08-26 21:42:04 -05:00
*
2011-08-31 00:07:45 -05:00
* 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.
2011-08-26 21:42:04 -05:00
*/
public function __get($key)
{
2011-08-31 00:07:45 -05:00
if (IoC::container()->registered('laravel.'.$key))
2011-08-26 21:42:04 -05:00
{
2011-08-31 00:07:45 -05:00
return IoC::container()->resolve('laravel.'.$key);
2011-08-26 21:42:04 -05:00
}
2011-08-31 00:07:45 -05:00
elseif (IoC::container()->registered($key))
2011-08-26 21:42:04 -05:00
{
2011-08-31 00:07:45 -05:00
return IoC::container()->resolve($key);
2011-08-26 21:42:04 -05:00
}
2011-08-31 00:07:45 -05:00
throw new \Exception("Attempting to access undefined property [$key].");
2011-08-26 21:42:04 -05:00
}
2011-08-31 00:07:45 -05:00
}
class Application extends Resolver {
/**
* The IoC container instance for the application.
*
* @var Container
*/
public $container;
2011-08-26 21:42:04 -05:00
}