本文整理汇总了PHP中Illuminate\Foundation\Application::make方法的典型用法代码示例。如果您正苦于以下问题:PHP Application::make方法的具体用法?PHP Application::make怎么用?PHP Application::make使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Illuminate\Foundation\Application
的用法示例。
在下文中一共展示了Application::make方法的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:
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);
}
示例3: fire
/**
* Execute the console command.
*
* @return mixed
*/
public function fire()
{
$this->app = $this->getLaravel();
$this->config = $this->app->make('config');
$options = $this->processOptions();
$options['extensions'] = 'php';
$options['colors'] = $this->getOutput()->isDecorated();
$command = $this->buildCommand($this->binPath . '/phpcs', $options);
$this->info('Running PHP Code Sniffer...');
$this->info($command);
passthru($command, $exitCode);
$this->info('Done.');
if (!$this->option('no-interaction') && $exitCode !== 0) {
$answer = $this->ask('Try to automatically fix issues? [Yn]', 'y');
if (strtolower($answer) == 'n') {
$this->info('Declined fixes.');
return $exitCode;
}
// Code beautifier takes all the same options (except for colors).
unset($options['colors']);
$command = $this->buildCommand($this->binPath . '/phpcbf', $options);
$this->info('Running PHP Code Beautifier...');
$this->info($command);
passthru($command, $exitCode);
$this->info('Done.');
}
return $exitCode;
}
示例4: 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('blade.compiler');
$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);
});
}
}
示例5: process
public function process(LocalezeRequest $request)
{
$username = $this->app->make('config')->get('laravel-localeze::username');
$password = $this->app->make('config')->get('laravel-localeze::password');
$response = $this->soap->query(["origination" => $this->setupOrigination($username, $password), "transId" => 1, "serviceId" => $this->serviceId, "elements" => $request->elements, "serviceKeys" => $request->serviceKeys]);
return new LocalezeResponse($response);
}
示例6: testRegister
public function testRegister()
{
$provider = new InlinerServiceProvider($this->app);
$provider->register();
$this->assertTrue($this->app->bound('Chromabits\\Illuminated\\Contracts\\Inliner\\StyleInliner'));
$this->assertInstanceOf('Chromabits\\Illuminated\\Contracts\\Inliner\\StyleInliner', $this->app->make('Chromabits\\Illuminated\\Contracts\\Inliner\\StyleInliner'));
}
示例7: __construct
public function __construct(DatabaseManager $db, Application $app, Config $config)
{
$this->app = $app;
$this->config = $config;
$this->db = $db;
$this->roleModel = $this->app->make($this->config->get('laravel-rbac.roleModel'));
}
示例8: call
/**
* @param $method
* @param $resourceName
* @param $uri
* @param $inputs
* @param $key
* @param $signature
* @throws APIException
* @return mixed
*/
public function call($method, $resourceName, $uri, $inputs, $key, $signature)
{
// Get resource data containing: action and arguments
$resourceData = ResourceData::make($uri, $method);
// If can't get resource by name from the respoitory throw an exception because resource doesn't exists
if (!($resource = $this->app->make('Lifeentity\\Api\\ResourceRepository')->getByName($resourceName))) {
throw new APIException("We can't find this resource in our application: {{$resourceName}}");
}
// Get application by the api key
if (!($application = $this->app->make('Lifeentity\\Api\\APIApplication')->byApiKey($key)->first())) {
throw new APIPermissionException("The api key is incorrect.");
}
// Check signature
if (!$application->checkSignature($signature)) {
throw new APIPermissionException("The api signature is incorrect.");
}
// Check if this application has permissions to access this resource and action
if (!$application->checkPermissions($resource->name(), $resourceData->getAction())) {
throw new APIPermissionException("You don't have permissions to request `{$resourceData->getAction()}` on this resource: {{$resource->name()}}");
}
// Set inputs for this resource
$resource->setInputs(new InputData($inputs));
// Now every thing is ready, call this resource
return $resource->call($resourceData);
}
示例9: 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}.");
}
示例10: renderFromPost
/**
* @param Post $post
*
* @return string
*/
public function renderFromPost(Post $post)
{
$post = $this->app->make('MyBB\\Core\\Presenters\\Post', [$post]);
$message = $post->content;
// TODO: MarkdownQuoteRenderer
return "> {$message}\n\n";
}
示例11: execute
/**
* @param $command
* @return mixed
*/
public function execute($command)
{
$validator = $this->commandTranslator->toCommandValidator($command);
if (class_exists($validator)) {
$this->app->make($validator)->validate($command);
}
return $this->commandBus->execute($command);
}
示例12: registerRegistersTheServiceProvider
/**
* @test
* @covers Cocur\Slugify\Bridge\Laravel\SlugifyServiceProvider::register()
*/
public function registerRegistersTheServiceProvider()
{
$this->provider->register();
// the service provider is deferred, so this forces it to load
$this->app->make('slugify');
$this->assertArrayHasKey('slugify', $this->app);
$this->assertInstanceOf('Cocur\\Slugify\\Slugify', $this->app['slugify']);
}
示例13: write
/**
* @param $contents
*/
private function write($contents)
{
$config = $this->app->make('Illuminate\\Config\\Repository');
$routesFile = $config->get('api::paths.routes_file');
$handler = fopen($routesFile, 'a');
fwrite($handler, $contents);
fclose($handler);
}
示例14: __construct
/**
* Constructor.
*
* @param Application $app
*/
public function __construct(Application $app)
{
$this->app = $app;
$this->httpKernel = $this->app->make('Illuminate\\Contracts\\Http\\Kernel');
$this->httpKernel->bootstrap();
$this->app->boot();
parent::__construct($this);
}
示例15: handle
/**
* Handle the event.
*
* @param $event
*
* @return mixed
*/
public function handle($event)
{
// Check to see if a handler exists for this event
// If the handler does exist, resolve it from the IoC container and call it's fire() method
if ($handler = $this->getHandler($event)) {
$this->app->make($handler)->fire($event);
}
}