本文整理汇总了PHP中Illuminate\Contracts\Foundation\Application类的典型用法代码示例。如果您正苦于以下问题:PHP Application类的具体用法?PHP Application怎么用?PHP Application使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Application类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setupSeeds
/**
* Setup the seeds.
*
* @param \Illuminate\Contracts\Foundation\Application $app
*
* @return void
*/
protected function setupSeeds(Application $app)
{
$source = realpath(__DIR__ . '/../database/seeds/');
if ($app instanceof LaravelApplication && $app->runningInConsole()) {
$this->publishes([$source => database_path('seeds')], 'seeds');
}
}
示例2: attach
/**
* Instanciate and execute all functions as blade extends
*
* @param Application $app The current application
*/
public static function attach(Application $app)
{
/** @var \Illuminate\View\Compilers\BladeCompiler $blade */
$blade = $app->make('view')->getEngineResolver()->resolve('blade')->getCompiler();
$config = $app->make('config');
$class = new static();
if (!isset($class->directivesFile)) {
$class->directivesFile = __DIR__ . '/../directives.php';
}
$blacklist = isset($class->blacklist) ? $class->blacklist : $config->get('blade_extensions.blacklist');
$directives = isset($class->directives) ? $class->directives : $app->make('files')->getRequire($class->directivesFile);
$overrides = isset($class->overrides) ? $class->overrides : $config->get('blade_extensions.overrides', []);
foreach ($overrides as $method => $override) {
if (!isset($directives[$method])) {
continue;
}
if (isset($override['pattern'])) {
$directives[$method]['pattern'] = $override['pattern'];
}
if (isset($override['replacement'])) {
$directives[$method]['replacement'] = $override['replacement'];
}
}
foreach ($directives as $name => $directive) {
$method = 'directive' . ucfirst($name);
if (is_array($blacklist) && in_array($name, $blacklist, true) || !method_exists($class, $method)) {
continue;
}
$blade->extend(function ($value) use($class, $method, $directive, $app, $blade) {
return $class->{$method}($value, $directive['pattern'], $directive['replacement'], $app, $blade);
});
}
}
示例3: let
function let(Application $app, ContainerInterface $container)
{
$container->addPackage('mvalim/package')->shouldBeCalled();
$app->make('Mvalim\\PackageUtils\\Container')->willReturn($container);
$this->beAnInstanceOf('spec\\Mvalim\\PackageUtils\\Providers\\CorrectProviderStub');
$this->beConstructedWith($app);
}
示例4: bootstrap
/**
* Bootstrap the given application.
*
* @param \Illuminate\Contracts\Foundation\Application $app
* @return void
*/
public function bootstrap(Application $app)
{
//Detect the domain
$app->detectDomain();
//Overrides the storage path if the domain staorge path exists
$app->useStoragePath($app->domainStoragePath());
}
示例5: setupMigrations
/**
* Setup the migrations.
*
* @param \Illuminate\Contracts\Foundation\Application $app
*
* @return void
*/
protected function setupMigrations(Application $app)
{
$source = realpath(__DIR__ . '/../database/migrations/');
if (class_exists('Illuminate\\Foundation\\Application', false) && $app->runningInConsole()) {
$this->publishes([$source => database_path('migrations')], 'migrations');
}
}
示例6: initMigration
/**
* Copy migration to resources
*
* @param Application $app
*/
private function initMigration(Application $app)
{
if ($app instanceof \Illuminate\Foundation\Application && $app->runningInConsole()) {
$migrationPath = realpath(__DIR__ . '/../database/migrations');
$this->publishes([$migrationPath => database_path('migrations')]);
}
}
示例7: bootstrap
/**
* Bootstrap the given application.
*
* @param \Illuminate\Contracts\Foundation\Application $app
*
* @return void
*/
public function bootstrap(Application $app)
{
$items = [];
$app->instance('config', $config = new Repository($items));
$this->loadConfigurationFiles($app, $config);
mb_internal_encoding('UTF-8');
}
示例8: __construct
/**
* Create a new instance of Storytelling.
*
* @param \Illuminate\Contracts\Foundation\Application $app
*/
public function __construct($app)
{
$this->app = $app;
if (method_exists($this, 'initiate')) {
$app->call([$this, 'initiate']);
}
}
示例9: boot
public function boot(Application $app)
{
$source = realpath(__DIR__ . '/migrations/');
if ($app->runningInConsole()) {
$this->publishes([$source => database_path('migrations')], 'migrations');
}
}
示例10: __construct
public function __construct(Application $app)
{
$providers_classes = config('preview.screenshot_providers');
foreach ($providers_classes as $class) {
$this->providers[] = $app->make($class);
}
}
示例11: handle
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next)
{
if (!$request->secure() && $this->app->environment() === 'production') {
return redirect()->secure($request->getRequestUri());
}
return $next($request);
}
示例12: isRunningInConsole
/**
* Determine if the app is running in the console.
*
* To allow testing this will return false the environment is testing.
*
* @return bool
*/
public function isRunningInConsole()
{
if ($this->app->environment('testing')) {
return false;
}
return $this->app->runningInConsole();
}
示例13: handle
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next)
{
if ($this->app->isDownForMaintenance()) {
throw new HttpException(503);
}
return $next($request);
}
示例14: sendRequestThroughRouter
/**
* Send through our custom router
*
* @param $request
*
* @return Response
*/
protected function sendRequestThroughRouter($request)
{
$this->app->instance('request', $request);
return (new Pipeline($this->app))->send($request)->through($this->middleware)->then(function ($request) {
return $this->router->dispatch($this->alexaRequest);
});
}
示例15: handle
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return void|mixed
*/
public function handle(Request $request, Closure $next)
{
if (!$this->app->isDownForMaintenance()) {
return $next($request);
}
if ($request->segment(1) == 'admin') {
return $next($request);
}
if (in_array($request->getClientIp(), $this->config->get('streams::maintenance.ip_whitelist', []))) {
return $next($request);
}
/* @var UserInterface $user */
$user = $this->guard->user();
if ($user && $user->isAdmin()) {
return $next($request);
}
if ($user && $this->authorizer->authorize('streams::maintenance.access')) {
return $next($request);
}
if (!$user && $this->config->get('streams::maintenance.auth')) {
/* @var Response|null $response */
$response = $this->guard->onceBasic();
if (!$response) {
return $next($request);
}
$response->setContent(view('streams::errors.401'));
return $response;
}
abort(503);
}