本文整理汇总了PHP中Illuminate\Support\Facades\Facade类的典型用法代码示例。如果您正苦于以下问题:PHP Facade类的具体用法?PHP Facade怎么用?PHP Facade使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Facade类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
public function __construct($values = array())
{
parent::__construct();
static::$app = $this;
foreach ($values as $key => $value) {
$this[$key] = $value;
}
Facade::setFacadeApplication($this);
// register the configserviceprovider so we can access the config
$this->register(new ConfigServiceProvider());
// grab the providers from the config and load them
$providers = $this['config']->get('app/providers');
foreach ($providers as $provider) {
$this->register(new $provider());
}
// set the locale (https://github.com/silexphp/Silex/issues/983)
$locale = $values['locale'];
if ($this['translator']) {
$this['translator']->setlocale($locale);
}
// register fieldtypes from config
$fieldTypesConfig = $this['config']->get('fieldtypes');
if ($fieldTypesConfig) {
$this['fieldtypes'] = $this['fieldtypes.factory']->fromConfig($fieldTypesConfig);
}
// register contenttypes from config
$contentTypeConfig = $this['config']->get('contenttypes');
if ($contentTypeConfig) {
$this['contenttypes'] = $this['contenttypes.factory']->fromConfig($contentTypeConfig);
}
}
示例2: sendRequestThroughRouter
/**
* Send the given request through the middleware / router.
*
* @param \Illuminate\Http\Request $request
*
* @return \Illuminate\Http\Response
*/
protected function sendRequestThroughRouter($request)
{
$this->app->instance('request', $request);
Facade::clearResolvedInstance('request');
$this->bootstrap();
// If administration panel is attempting to be displayed,
// we don't need any response
if (is_admin()) {
return;
}
// Get response on `template_include` filter so the conditional functions work correctly
add_filter('template_include', function ($template) use($request) {
// If the template is not index.php, then don't output anything
if ($template !== get_template_directory() . '/index.php') {
return $template;
}
try {
$response = (new Pipeline($this->app))->send($request)->through($this->app->shouldSkipMiddleware() ? [] : $this->middleware)->then($this->dispatchToRouter());
} catch (Exception $e) {
$this->reportException($e);
$response = $this->renderException($request, $e);
} catch (Throwable $e) {
$this->reportException($e = new FatalThrowableError($e));
$response = $this->renderException($request, $e);
}
$this->app['events']->fire('kernel.handled', [$request, $response]);
return $template;
}, PHP_INT_MAX);
}
示例3: setUp
/**
* Bootstrap the test environemnt:
* - Create an application instance and register it within itself.
* - Register the package service provider with the app.
* - Set the APP facade.
*
* @return void
*/
public function setUp()
{
$app = new Application();
$app->instance('app', $app);
$app->register('Codesleeve\\LaravelStapler\\LaravelStaplerServiceProvider');
Facade::setFacadeApplication($app);
}
示例4: bootstrap
public function bootstrap(Application $app, $config)
{
\Illuminate\Support\Facades\Facade::clearResolvedInstances();
\Illuminate\Support\Facades\Facade::setFacadeApplication($app);
#注册别名并设置自动加载器
\Illuminate\Foundation\AliasLoader::getInstance($config['app_aliases'])->register();
}
示例5: resolveFacadeInstance
/**
* {@inheritDoc}
*/
protected static function resolveFacadeInstance($name)
{
if (!is_object($name) && !static::$app->bound($name) && ($instance = static::getFacadeInstance()) !== null) {
static::$app->instance($name, $instance);
}
return parent::resolveFacadeInstance($name);
}
示例6: reboot
/**
* After each scenario, reboot the kernel.
*/
public function reboot()
{
Facade::clearResolvedInstances();
$lumen = new LumenBooter($this->app->basePath());
$this->context->getSession('lumen')->getDriver()->reboot($this->app = $lumen->boot());
$this->setAppOnContext();
}
示例7: getApp
protected function getApp($service = null)
{
if ($service) {
return Facade::getFacadeApplication()->make($service);
}
return Facade::getFacadeApplication();
}
示例8: register
public function register()
{
$this->app->container->singleton('ioc', function () {
return new Container();
});
Facade::setFacadeApplication($this->app->ioc);
}
示例9: create
public static function create()
{
$instance = new self();
// Swap the Facade app with our container (to use these mocks)
Facade::setFacadeApplication($instance->app);
return $instance->app;
}
示例10: it_should_get_a_proxy
/**
* @test
*/
public function it_should_get_a_proxy()
{
/**
*
* Set
*
*/
$proxy = m::mock('Iverberk\\Larasearch\\proxy');
/**
*
* Expectation
*
*/
Facade::clearResolvedInstances();
\Husband::clearProxy();
App::shouldReceive('make')->with('iverberk.larasearch.proxy', m::type('Illuminate\\Database\\Eloquent\\Model'))->andReturn($proxy);
/**
*
*
* Assertion
*
*/
$proxy1 = \Husband::getProxy();
$this->assertSame($proxy, $proxy1);
$proxy2 = \Husband::getProxy();
$this->assertSame($proxy, $proxy2);
}
示例11: sendRequestThroughRouter
/**
* Send the given request through the middleware / router.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response
*/
protected function sendRequestThroughRouter($request)
{
$this->app->instance('request', $request);
Facade::clearResolvedInstance('request');
$this->bootstrap();
return (new Pipeline($this->app))->send($request)->through($this->middleware)->then($this->dispatchToRouter());
}
示例12: __callStatic
public static function __callStatic($method, $args)
{
// subhelper
if (empty($args)) {
return LaravelFacade::getFacadeApplication()->helpers->subhelper($method);
}
}
示例13: setUp
public function setUp()
{
$app = M::mock('Application');
$app = $app->shouldReceive('make')->with('path.public')->andReturn('tmp');
$app = $app->shouldReceive('make')->with('path')->andReturn('tests');
$app = $app->mock();
Facade::setFacadeApplication($app);
}
示例14: testMapping
public function testMapping()
{
Facade::setFacadeApplication(new ApplicationStub());
$configuration = ['driver' => 'sqlite', 'database' => 'db', 'username' => 'somedude', 'prefix' => 'mitch_', 'charset' => 'whatevs'];
$expected = ['driver' => 'pdo_sqlite', 'path' => 'path/database/db.sqlite', 'user' => $configuration['username']];
$actual = $this->sqlMapper->map($configuration);
$this->assertEquals($expected, $actual);
}
示例15: sendRequestThroughRouter
/**
* Send the given request through the middleware / router.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response
*/
protected function sendRequestThroughRouter($request)
{
$this->app->instance('request', $request);
Facade::clearResolvedInstance('request');
$this->bootstrap();
$shouldSkipMiddleware = $this->app->bound('middleware.disable') && $this->app->make('middleware.disable') === true;
return (new Pipeline($this->app))->send($request)->through($shouldSkipMiddleware ? [] : $this->middleware)->then($this->dispatchToRouter());
}