Get the application instance behind the facade.
public static getFacadeApplication ( ) : Illuminate\Contracts\Foundation\Application | ||
리턴 | Illuminate\Contracts\Foundation\Application |
protected function getApp($service = null) { if ($service) { return Facade::getFacadeApplication()->make($service); } return Facade::getFacadeApplication(); }
public static function __callStatic($method, $args) { // subhelper if (empty($args)) { return LaravelFacade::getFacadeApplication()->helpers->subhelper($method); } }
/** * Create a new Console application. * * @param null $app * * @return Artisan */ public static function make($app = null) { if (!static::$instance) { /** @var Application $app */ $app = Facade::getFacadeApplication(); /** @var Artisan $console */ $console = with($console = new static('Laravel Database', '4.2.*'))->setLaravel($app)->setExceptionHandler($app['exception'])->setAutoExit(false); $app->instance('artisan', $console); static::registerServiceProviders($app); $console->add(new AutoloadCommand()); $console->add(new ServeCommand()); $console->add(new ModelMakeCommand($app['files'])); $console->add(new CommandMakeCommand($app['files'])); $console->add(new EnvironmentCommand()); $console->add(new EnvironmentCommand()); static::$instance = $console; } return static::$instance; }
protected function isRunningWithFacades() { return Facade::getFacadeApplication() !== null; }
/** * Filters a route for the permission. If the third parameter * is null then return 403. Overwise the $result is returned * * @param string $route Route pattern. i.e: "admin/*" * @param array|string $roles The role(s) needed. * @param array|string $permissions The permission needed. * @param mixed $result i.e: Redirect::to('/') * @param bool $cumulative Must have all permissions * * @access public * * @return void */ public function routeNeedsRoleOrPermission($route, $roles, $permissions, $result = null, $cumulative = false) { if (!is_array($roles)) { $roles = array($roles); } if (!is_array($permissions)) { $permissions = array($permissions); } $filter_name = implode('_', $roles) . '_' . implode('_', $permissions) . '_' . substr(md5($route), 0, 6); if (!$result instanceof Closure) { $result = function () use($roles, $permissions, $result, $cumulative) { $hasARole = array(); foreach ($roles as $role) { if ($this->hasRole($role)) { $hasARole[] = true; } else { $hasARole[] = false; } } $hasAPermission = array(); foreach ($permissions as $permission) { if ($this->can($permission)) { $hasAPermission[] = true; } else { $hasAPermission[] = false; } } // Check to see if it is false and then // check additive flag and that the array only contains false. if ((in_array(false, $hasARole) || in_array(false, $hasAPermission)) && ($cumulative || count(array_unique(array_merge($hasARole, $hasAPermission))) == 1)) { if (!$result) { Facade::getFacadeApplication()->abort(403); } return $result; } }; } // Same as Route::filter, registers a new filter $this->_app['router']->filter($filter_name, $result); // Same as Route::when, assigns a route pattern to the // previously created filter. $this->_app['router']->when($route, $filter_name); }
/** * Return a new view response from the application. * * @param string $view * @param array $data * @param int $status * @param array $headers * @return \Illuminate\Http\Response */ public static function view($view, $data = array(), $status = 200, array $headers = array()) { $app = Facade::getFacadeApplication(); return static::make($app['view']->make($view, $data), $status, $headers); }
public function testServiceProvider() { $this->assertCount(3, Facade::getFacadeApplication()->getLoadedProviders()); }