本文整理汇总了PHP中Illuminate\Support\Facades\App类的典型用法代码示例。如果您正苦于以下问题:PHP App类的具体用法?PHP App怎么用?PHP App使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了App类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: api
/**
* Get the API ancestor controller class
* of the current controller class.
*
* @return Esensi\Core\Http\Controllers\ApiController
*/
public function api()
{
// Make a copy of the parent class
$class = get_parent_class();
$parent = App::make($class);
// Copy over the packaged properties
if ($this instanceof PackagedInterface) {
$parent->setUI($this->getUI());
$parent->setPackage($this->getPackage());
$parent->setNamespacing($this->getNamespacing());
}
// Copy over the injected repositories
if ($this instanceof RepositoryInjectedInterface) {
foreach ($this->repositories as $name => $repository) {
$parent->setRepository($repository, $name);
}
}
// Return first ApiController ancestor found
if (str_contains($class, 'ApiController')) {
return $parent;
}
// Recursively look up the parent class
if (method_exists($parent, 'api')) {
return $parent->api();
}
// Return the parent class found already
return $parent;
}
示例2: testCommands
/**
* Do the Artisan commands fire?
*/
public function testCommands()
{
$self = $this;
$this->prepareSpecify();
$this->specify('Boots', function () use($self) {
$target = $self->getProvider(['package']);
$target->shouldReceive('package');
$target->boot();
});
$this->prepareSpecify();
$this->specify('Identifies provisions', function () use($self) {
$target = $self->getProvider();
verify($target->provides())->notEmpty();
});
$this->prepareSpecify();
$this->specify('Binds to application', function () use($self) {
App::shouldReceive('bind')->with('/^toolbox\\.commands\\./', Mockery::on(function ($closure) {
$command = $closure();
verify_that('is a command', is_a($command, 'Illuminate\\Console\\Command'));
return true;
}));
Event::shouldReceive('listen')->with('toolbox.build', Mockery::on(function ($closure) {
$app = Mockery::mock('Illuminate\\Console\\Application[call]');
$app->shouldReceive('call');
$command = $closure($app);
return true;
}));
$target = $self->getProvider(['commands']);
$target->shouldReceive('commands')->with(Mockery::type('array'));
$target->register();
});
}
示例3: setSupportedLanguage
/**
* @param string $lang
*/
private function setSupportedLanguage($lang)
{
if ($this->isLanguageSupported($lang)) {
App::setLocale($lang);
Session::put('lang', $lang);
}
}
示例4: getReset
/**
* Display the password reset view for the given token.
*
* @param string $token
* @return \Response
*/
public function getReset($token = null)
{
if (is_null($token)) {
App::abort(404);
}
$this->view('password.reset', ['token' => $token]);
}
示例5: display
/**
* Display the content of the page
*
* @param $query
* @return \Illuminate\View\View
*/
public function display($query)
{
$title = 'TestView';
$page = "";
$arr = explode('/', $query);
// \App\Page::find(4)->content->find(5)->element->module->name
$heading = \App\Node::findBySlug('header');
// dd(\App\Node::findBySlug($arr[0])->content);
// test
$content = \App\Node::active()->findBySlug($arr[0])->content;
foreach ($content as $item) {
// get the module Name of
// $module = \App\Module::findOrFail($p->module_id);
// resolve the Module Name out of the IOC Container and render the content partiall
// $content .= App::make('module:' . $module->name)->render($p->content_id);
// foreach ($item->content as $content)
// {
//Todo check if Module is Active and Content is Active
$module = $item->element->module->name;
if ($module != 'Heading') {
continue;
}
// resolve the Module out of the IOC Container and render the partial
$page .= App::make('module:' . strtolower($module))->render($item->element->row);
// }
}
return view('layout.master', compact('title', 'page'));
}
示例6: getTraining
public function getTraining()
{
$training = new \Offside\Team\Training($this->trainingRepository);
$javascript = App::make('Javascript');
$javascript::put(['attackTraining' => $training->getAttackDateTime(), 'midfieldTraining' => $training->getMidfieldDateTime(), 'defenseTraining' => $training->getDefenseDateTime(), 'anyTrainingActive' => !$training->allTrainingsDone(), 'elapsedTime' => $training->getElapsedTime()]);
return view("my-team.training");
}
示例7: bootSilverstripe
protected function bootSilverstripe($url = null)
{
$flush = $this->option('flush');
// to allow the Silverstripe command line to know what the server URL should be ...
// sadly, setting a global $_FILE_TO_URL_MAPPING variable is not enough because Silverstripe's Core.php (or
// Constants.php in newer versions) doesn't declare it as global - it assumes it's declared in the
// _ss_environment.php file which is _included_ not _required_. Boo.
// global $_FILE_TO_URL_MAPPING;
// $_FILE_TO_URL_MAPPING[base_path()] = Config::get('app.url');
$base = base_path();
$envPath = $base . '/_ss_environment.php';
if (!file_exists($envPath)) {
$appUrl = Config::get('app.url');
file_put_contents($envPath, <<<EOT
<?php
global \$_FILE_TO_URL_MAPPING;
\$_FILE_TO_URL_MAPPING['{$base}'] = '{$appUrl}';
EOT
);
App::shutdown(function ($app) use($envPath) {
unlink($envPath);
});
}
// taken from silverstripe's framework/cli-script.php
if ($flush) {
$_REQUEST['flush'] = $flush === true ? 1 : $flush;
$_GET['flush'] = $flush === true ? 1 : $flush;
}
if ($url) {
$_REQUEST['url'] = $url;
$_GET['url'] = $url;
}
Silverstripe::start();
}
示例8: handle
/**
* Handle the command
*
* @param BaseCommand|RegisterUserCommand $command
*
* @return mixed
*/
public function handle(BaseCommand $command)
{
$user = new User($command->all());
$user->save();
App::make('Altwallets\\Services\\UserMailer')->sendRegistrationEmail($user);
return $user;
}
示例9: register
/**
* Register the application services.
*
* @return void
*/
public function register()
{
$this->mergeConfigFrom(__DIR__ . '/../../config/smsc.php', 'smsc');
App::bind('smsc', function () {
return new Smsc();
});
}
示例10: it_should_fire_job_with_unresolvable_models
/**
* @test
*/
public function it_should_fire_job_with_unresolvable_models()
{
/**
*
* Set
*
*/
App::shouldReceive('make')->with('menthol.flexible.proxy', Mockery::any())->once()->andReturn('mock');
$app = m::mock('Illuminate\\Foundation\\Application');
$config = m::mock('Menthol\\Flexible\\Config');
$logger = m::mock('Monolog\\Logger');
$job = m::mock('Illuminate\\Queue\\Jobs\\Job');
$models = ['Husband:99999'];
/**
*
* Expectation
*
*/
$logger->shouldReceive('info')->with('Indexing Husband with ID: 99999');
$logger->shouldReceive('error')->with('Indexing Husband with ID: 99999 failed: No query results for model [Husband].');
$config->shouldReceive('get')->with('logger', 'menthol.flexible.logger')->andReturn('menthol.flexible.logger');
$app->shouldReceive('make')->with('menthol.flexible.logger')->andReturn($logger);
$job->shouldReceive('delete')->once();
$job->shouldReceive('release')->with(60)->once();
/**
*
* Assertion
*
*/
with(new ReindexJob($app, $config))->fire($job, $models);
}
示例11: __construct
public function __construct()
{
$this->request = App::make('request');
$this->config = App::make('config');
$this->restResponse = App::make('Noherczeg\\RestExt\\Services\\ResponseComposer');
$this->linker = App::make('Noherczeg\\RestExt\\Services\\Linker');
$this->restExt = App::make('Noherczeg\\RestExt\\RestExt');
if ($this->accessPolicy === null) {
$this->accessPolicy = $this->config->get('restext::access_policy');
}
// if we set the property it should override the Accept Header even if it it is set otherwise in the configs
if ($this->produces !== null) {
$this->produce($this->produces);
}
$securityRoles = $this->securityRoles;
$accessPolicy = $this->accessPolicy;
// Default actions
$this->beforeFilter(function () use($securityRoles, $accessPolicy) {
// To prevent processing / returning of content if by default the access policy is set to
// "whitelist" and no allowed roles have been set.
if ($accessPolicy == 'whitelist' && count($securityRoles) == 0) {
throw new PermissionException();
}
// If the "prefer_accept" configuration is set to true, we set RestResponse to send the MediaType given in
// the Accept Header if it's compatible with our system. If not we set it to the default config's value.
if ($this->config->get('restext::prefer_accept')) {
if (in_array($this->requestAccepts(), $this->restResponse->getSupportedMediaTypes())) {
$this->restResponse->setMediaType($this->requestAccepts());
}
$this->restResponse->setMediaType($this->config->get('restext::media_type'));
}
});
}
示例12: __construct
/**
* Profiler constructor.
*/
public function __construct()
{
$this->profiler = App::make('profiler');
if ($this->profiler instanceof NullProfiler) {
abort(500, 'Profiler is not instantiate correctly.');
}
}
示例13: testCreateThrowsExceptionWhenMissingDefaultConfiguration
/**
* @expectedException \Publiux\laravelcdn\Exceptions\MissingConfigurationException
*/
public function testCreateThrowsExceptionWhenMissingDefaultConfiguration()
{
$configurations = ['default' => ''];
$m_aws_s3 = M::mock('Publiux\\laravelcdn\\Providers\\AwsS3Provider');
\Illuminate\Support\Facades\App::shouldReceive('make')->once()->andReturn($m_aws_s3);
$this->provider_factory->create($configurations);
}
示例14: getIconAttribute
/**
* Returns an html icon class of the type of
* notification by retrieving it from the configuration file.
*
* @return string|null
*/
public function getIconAttribute()
{
$class = $this->attributes['notifiable_type'];
/*
* Resolve the configuration service from the IoC since
* we don't want to override the Notification models constructor
* to inject the service
*/
$config = App::make(ConfigService::class);
// Make sure we have an instance of the ConfigService returned by the IoC
if ($config instanceof ConfigService) {
$icon = $config->setPrefix('maintenance')->get("notifications.icons.{$class}");
// Return the models notification icon if it's found
if (is_string($icon) && !empty($icon)) {
return $icon;
}
/*
* Looks like the notification icon could not be
* found, we'll return the default notification icon
*/
$defaultIcon = $config->setPrefix('maintenance')->get('notifications.icons.default');
return $defaultIcon;
}
return;
}
示例15: register
/**
* Register any package services.
*
* @return void
*/
public function register()
{
App::bind('VKAPI', function () {
return new VKAPIClass(config('VKAPI.access_token'), config('VKAPI.version'), config('VKAPI.api_url'));
});
$this->publishes([__DIR__ . '/../config/VKAPI.php' => config_path('VKAPI.php')]);
}