本文整理汇总了PHP中Illuminate\Foundation\Application类的典型用法代码示例。如果您正苦于以下问题:PHP Application类的具体用法?PHP Application怎么用?PHP Application使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Application类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: initialize
/**
* Initialize the Laravel framework.
*/
private function initialize()
{
// Store a reference to the database object
// so the database connection can be reused during tests
$oldDb = null;
if ($this->app['db'] && $this->app['db']->connection()) {
$oldDb = $this->app['db'];
}
// The module can login a user with the $I->amLoggedAs() method,
// but this is not persisted between requests. Store a reference
// to the logged in user to simulate this.
$loggedInUser = null;
if ($this->app['auth'] && $this->app['auth']->check()) {
$loggedInUser = $this->app['auth']->user();
}
$this->app = $this->kernel = $this->loadApplication();
$this->app->make('Illuminate\\Contracts\\Http\\Kernel')->bootstrap();
// Set the base url for the Request object
$url = $this->app['config']->get('app.url', 'http://localhost');
$this->app->instance('request', Request::createFromBase(SymfonyRequest::create($url)));
if ($oldDb) {
$this->app['db'] = $oldDb;
Model::setConnectionResolver($this->app['db']);
}
// If there was a user logged in restore this user.
// Also reload the user object from the user provider to prevent stale user data.
if ($loggedInUser) {
$refreshed = $this->app['auth']->getProvider()->retrieveById($loggedInUser->getAuthIdentifier());
$this->app['auth']->setUser($refreshed ?: $loggedInUser);
}
$this->module->setApplication($this->app);
}
示例2: __construct
/**
* Creates new instance.
*
* @param \Illuminate\Foundation\Application $app
* @param \Arcanedev\Localization\Contracts\RouteTranslatorInterface $routeTranslator
* @param \Arcanedev\Localization\Contracts\LocalesManagerInterface $localesManager
*/
public function __construct(Application $app, RouteTranslatorInterface $routeTranslator, LocalesManagerInterface $localesManager)
{
$this->app = $app;
$this->routeTranslator = $routeTranslator;
$this->localesManager = $localesManager;
$this->localesManager->setDefaultLocale($this->app->getLocale());
}
示例3: createApplication
public function createApplication()
{
$app = new Application();
$app->register(\Illuminate\Database\DatabaseServiceProvider::class);
$app->register(\ShiftOneLabs\LaravelNomad\LaravelNomadServiceProvider::class);
return $app;
}
示例4: refreshApplication
/**
* Refresh the application instance.
*
* @return void
*/
protected function refreshApplication()
{
$this->app = $this->createApplication();
$this->client = $this->createClient();
$this->app->setRequestForConsoleEnvironment();
$this->app->boot();
}
示例5: 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);
}
示例6: getApplication
public function getApplication()
{
$app = new Application();
$app->instance('path', __DIR__);
$app['path.storage'] = __DIR__ . '/storage';
// Monolog
$log = m::mock('Illuminate\\Log\\Writer');
$log->shouldReceive('getMonolog')->andReturn(m::mock('Monolog\\Logger'));
$app['log'] = $log;
// Config
$config = new Repository(m::mock('Illuminate\\Config\\LoaderInterface'), 'production');
$config->getLoader()->shouldReceive('addNamespace')->with('laravel-sentry', __DIR__);
$config->getLoader()->shouldReceive('cascadePackage')->andReturnUsing(function ($env, $package, $group, $items) {
return $items;
});
$config->getLoader()->shouldReceive('exists')->with('environments', 'laravel-sentry')->andReturn(false);
$config->getLoader()->shouldReceive('exists')->with('dsn', 'laravel-sentry')->andReturn(false);
$config->getLoader()->shouldReceive('exists')->with('level', 'laravel-sentry')->andReturn(false);
$config->getLoader()->shouldReceive('load')->with('production', 'config', 'laravel-sentry')->andReturn(array('environments' => array('prod', 'production'), 'dsn' => '', 'level' => 'error'));
$config->package('foo/laravel-sentry', __DIR__);
$app['config'] = $config;
// Env
$app['env'] = 'production';
return $app;
}
示例7: setupServiceProvider
public function setupServiceProvider(Application $app)
{
$provider = new StatsdServiceProvider($app);
$app->register($provider);
$provider->boot();
return $provider;
}
示例8:
function it_should_run(Application $application, ApiValidator $validator, IApiControllerGenerator $apiControllerGenerator)
{
$application->make('Jdecano\\Api\\ApiValidator')->willReturn($validator);
$validator->validate()->willReturn(null);
$application->make('Jdecano\\Api\\IApiControllerGenerator')->willReturn($apiControllerGenerator);
$apiControllerGenerator->make('User')->willReturn(null);
}
示例9: handle
/**
* Execute the command.
*
* @param Filesystem $fileSystem
* @param Application $app
* @param TranslationRepositoryInterface $repository
* @param Dispatcher $event
* @return Collection of Group
*/
public function handle(Filesystem $fileSystem, Application $app, TranslationRepositoryInterface $repository, Dispatcher $event)
{
$files = $fileSystem->allFiles($app->langPath());
/**
* Retrieves all local languages
*/
$languages = collect($files)->transform(function ($file) {
return $file->getRelativePath();
})->unique();
/**
* Save Database instance with all languages
*/
$database = $repository->languages();
/**
* List Only names
*/
$names = $database->pluck('name');
/**
* Create New Language for those which has been set locally
* but was not present yet on the database
*/
$newLanguages = $languages->merge($names)->diff($names)->map(function ($name) {
return $this->dispatch(new CreateLanguageCommand($name));
});
/**
* Announce LanguagesWasCreated
*/
if (!$newLanguages->isEmpty()) {
$event->fire(new LanguagesWasCreated($newLanguages));
}
/**
* Returns All languages
*/
return $database->merge($newLanguages);
}
示例10: setupServiceProvider
private function setupServiceProvider(Application $app)
{
$provider = new ApaiIOServiceProvider($app);
$app->register($provider);
$provider->boot();
return $provider;
}
示例11: initialize
/**
* Initialize the Laravel Framework.
*
* @throws ModuleConfig
*/
private function initialize()
{
// Store a reference to the database object
// so the database connection can be reused during tests
$oldDb = null;
if ($this->app['db'] && $this->app['db']->connection()) {
$oldDb = $this->app['db'];
}
// Store the current value for the router filters
// so it can be reset after reloading the application
$oldFiltersEnabled = null;
if ($router = $this->app['router']) {
$property = new \ReflectionProperty(get_class($router), 'filtering');
$property->setAccessible(true);
$oldFiltersEnabled = $property->getValue($router);
}
$this->app = $this->loadApplication();
$this->kernel = $this->getStackedClient();
$this->app->boot();
// Reset the booted flag of the Application object
// so the app will be booted again if it receives a new Request
$property = new \ReflectionProperty(get_class($this->app), 'booted');
$property->setAccessible(true);
$property->setValue($this->app, false);
if ($oldDb) {
$this->app['db'] = $oldDb;
Model::setConnectionResolver($this->app['db']);
}
if (!is_null($oldFiltersEnabled)) {
$oldFiltersEnabled ? $this->app['router']->enableFilters() : $this->app['router']->disableFilters();
}
$this->module->setApplication($this->app);
}
示例12: createApplication
/**
* Setup the test application
*
* @return \Illuminate\Foundation\Application
*/
public function createApplication()
{
$app = new Application();
$app->register(\Illuminate\Database\DatabaseServiceProvider::class);
$app->register(\SeBuDesign\SqlServerGrammar\SqlServerGrammarServiceProvider::class);
return $app;
}
示例13: testMethodCalls
public function testMethodCalls()
{
$id = uniqid('testMethodCallId');
$pass = [$id];
$expect = [$id, $this];
$this->applicationMock->expects($this->any())->method('make')->will($this->returnCallback(function ($make) {
switch ($make) {
case 'request':
return $this->requestMock;
case 'commode.common.resolver':
return $this->resolver;
case 'LaravelCommode\\Common\\Controllers\\CommodeControllerTest':
return $this;
}
dd(func_get_args());
}));
$this->requestMock->expects($this->at(0))->method('ajax')->will($this->returnValue(false));
$this->requestMock->expects($this->at(1))->method('ajax')->will($this->returnValue(false));
$this->requestMock->expects($this->at(2))->method('ajax')->will($this->returnValue(true));
$resolveMethodsReflection = new ReflectionProperty($this->controller, 'resolveMethods');
$resolveMethodsReflection->setAccessible(true);
$resolveMethodsReflection->setValue($this->controller, false);
$this->assertSame($pass, $this->controller->callAction('getSomeMethod', $pass));
$resolveMethodsReflection->setValue($this->controller, true);
$this->assertSame($expect, $this->controller->callAction('getSomeMethodResolve', $pass));
$separateRequestsReflection = new ReflectionProperty($this->controller, 'separateRequests');
$separateRequestsReflection->setAccessible(true);
$separateRequestsReflection->setValue($this->controller, true);
$this->requestMock->expects($this->any())->method('ajax')->will($this->returnValue(true));
$this->assertSame($expect, $this->controller->callAction('getSomeMethodResolve', $pass));
}
示例14: fire
/**
* Execute the console command.
*
* @throws \Bmartel\Transient\Exception\InvalidObjectTypeException
* @return mixed
*/
public function fire()
{
// If user provided a class as an argument,
// ensure its a valid class which implments \Bmartel\Transient\TransientPropertyInterface.
if ($class = $this->argument('modelClass')) {
// Parse the class
$model = $this->inputParser->parse($class);
$modelType = $this->app->make($model);
if (!$modelType instanceof TransientPropertyInterface) {
throw new InvalidObjectTypeException('Class does not implement \\Bmartel\\Transient\\TransientPropertyInterface');
}
}
// If user provided property options, parse them into an array for querying.
if ($properties = $this->option('properties')) {
$transientProperties = $this->inputParser->parseProperties($properties);
}
$result = null;
// Determine what parameters to base the transient removal on.
if (isset($transientProperties) && isset($modelType)) {
$result = $this->transient->deleteByModelProperty($modelType, $transientProperties);
} elseif (isset($modelType)) {
$result = $this->transient->deleteByModelType($modelType);
} elseif (isset($transientProperties)) {
$result = $this->transient->deleteByProperty($transientProperties);
} else {
$result = $this->transient->deleteAll();
}
$propertiesName = str_plural('property', $result);
// Report the result of the command
$this->info("All done! Removed {$result} transient {$propertiesName}.");
}
示例15: handle
/**
* Handle a request.
*
* @param SyfmonyRequest $request
* @param int $type
* @param bool $catch
* @return Response
*/
public function handle(SyfmonyRequest $request, $type = self::MASTER_REQUEST, $catch = true)
{
$request = Request::createFromBase($request);
$request->enableHttpMethodParameterOverride();
$this->app->bind('request', $request);
return $this->httpKernel->handle($request);
}