本文整理汇总了PHP中Illuminate\Foundation\Application::bind方法的典型用法代码示例。如果您正苦于以下问题:PHP Application::bind方法的具体用法?PHP Application::bind怎么用?PHP Application::bind使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Illuminate\Foundation\Application
的用法示例。
在下文中一共展示了Application::bind方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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);
}
示例2: setUp
/**
* Setup the test.
*/
protected function setUp()
{
parent::setUp();
$this->app = new Application();
$this->app->bind('config', function () {
return new Repository(['inliner' => ['paths' => ['stylesheets' => ['some/path/n/stuff']], 'options' => ['cleanup' => false, 'use_inline_styles_block' => false, 'strip_original_tags' => false, 'exclude_media_queries' => false]]]);
});
}
示例3: applyBindings
/**
* Apply the registered Laravel service container bindings.
*/
private function applyBindings()
{
foreach ($this->bindings as $abstract => $binding) {
list($concrete, $shared) = $binding;
$this->app->bind($abstract, $concrete, $shared);
}
}
示例4: getApplication
protected function getApplication($customConfig = [])
{
$app = new Application();
$app->instance('path', __DIR__);
$app['env'] = 'production';
$app['path.config'] = $this->root . '/config';
// Filesystem
$files = m::mock('Illuminate\\Filesystem\\Filesystem');
$app['files'] = $files;
// View
// $finder = m::mock('Illuminate\View\ViewFinderInterface');
// $finder->shouldReceive('addExtension');
// $app['view'] = new Factory(
// new EngineResolver(),
// $finder,
// m::mock('Illuminate\Events\Dispatcher')
// );
// $config_data = include $config_file;
// Config
$app['config'] = new Repository([]);
$app->bind('\\Illuminate\\Config\\Repository', function () use($app) {
return $app['config'];
});
return $app;
}
示例5: getEnvironmentSetUp
/**
* Define environment setup.
*
* @param \Illuminate\Foundation\Application $app
* @return void
*/
protected function getEnvironmentSetUp($app)
{
$app->bind('Tokenly\\XCPDClient\\Client', function () {
$client = m::mock('Tokenly\\XCPDClient\\Client');
$client->shouldReceive('get_asset_info')->with(['assets' => ['LTBCOIN']])->andReturn([$this->sampleLTBCoinAssetInfo()]);
return $client;
});
}
示例6: it_composes_a_view_using_each_view_composer
/** @test */
public function it_composes_a_view_using_each_view_composer()
{
$view = 'view.test';
$this->app->bind('Coderabbi\\Virtuoso\\Tests\\ComposerStub', function () {
$composer = new ComposerStub();
$this->composers[] = $composer;
return $composer;
});
$compositeComposer = new CompositeComposerStub($this->app);
$compositeComposer->setComposers(['Coderabbi\\Virtuoso\\Tests\\ComposerStub', 'Coderabbi\\Virtuoso\\Tests\\ComposerStub']);
$compositeComposer->compose($view);
// Should create two composers
$this->assertEquals(2, count($this->composers));
// Each composer should compose $view
foreach ($this->composers as $composer) {
$this->assertEquals($view, $composer->composedView);
}
}
示例7: getEnvironmentSetUp
/**
* Define environment setup.
*
* @param \Illuminate\Foundation\Application $app
* @return void
*/
protected function getEnvironmentSetUp($app)
{
$app->bind('Tokenly\\XCPDClient\\Client', function () {
$connection_string = getenv('XCPD_CONNECTION_STRING');
$rpc_user = getenv('XCPD_RPC_USER');
$rpc_password = getenv('XCPD_RPC_PASSWORD');
$client = new \Tokenly\XCPDClient\Client($connection_string, $rpc_user, $rpc_password);
return $client;
});
}
示例8: getEnvironmentSetUp
/**
* Define environment setup.
*
* @param \Illuminate\Foundation\Application $app
* @return void
*/
protected function getEnvironmentSetUp($app)
{
// Setup default database to use sqlite :memory:
$app['config']->set('database.default', 'testbench');
$app['config']->set('database.connections.testbench', ['driver' => 'sqlite', 'database' => ':memory:', 'prefix' => '']);
// Bind the stub tracker
$app->bind(StubTracker::class, function ($app) {
return new StubTracker($app, $app['events'], $app['config']);
});
$app[StubTracker::class]->registerRoute($app['router']);
parent::getEnvironmentSetUp($app);
}
示例9: getEnvironmentSetUp
/**
* Define environment setup.
*
* @param \Illuminate\Foundation\Application $app
*
* @return void
*/
protected function getEnvironmentSetUp($app)
{
// Set Testing Configuration
$app['config']->set('database.default', 'testbench');
$app['config']->set('database.connections.testbench', ['driver' => 'sqlite', 'database' => __DIR__ . '/_data/database.sqlite', 'prefix' => '']);
$app['config']->set('mail.pretend', true);
$app['config']->set('mail.from', ['from' => 'noreply@example.com', 'name' => null]);
// Temporary Repository Bindings
// Bind the Transaction Repository
$app->bind('SRLabs\\Groundwork\\Repositories\\Transactions\\TransactionRepositoryInterface', function ($app) {
return new EloquentTransactionRepository(new Transaction(), $app->make('cache.store'), $app->make('events'), $app->make('log'));
});
}
示例10: bind
/**
* Register a binding with the container.
*
* @param string|array $abstract
* @param \Closure|string|null $concrete
* @param bool $shared
* @return void
* @static
*/
public static function bind($abstract, $concrete = null, $shared = false)
{
//Method inherited from \Illuminate\Container\Container
\Illuminate\Foundation\Application::bind($abstract, $concrete, $shared);
}
示例11: bindClasses
/**
* @param Application $app
*/
protected function bindClasses($app)
{
$app->bind(TagVersionManagerInterface::class, TagVersionManager::class);
$app->bind(TagVersionStorageInterface::class, function () use($app) {
return new PlainRedisTagVersionStorage($app['redis'], 'test_connection', 'tag_test');
});
$app->bind(SerializerInterface::class, GenericSerializer::class);
$app->bind(CoderManagerInterface::class, GenericCoderManager::class);
}
示例12: getEnvironmentSetUp
/**
* Define environment setup.
*
* @param \Illuminate\Foundation\Application $app
* @return void
*/
protected function getEnvironmentSetUp($app)
{
$app->bind('Reloquent\\Contracts\\ReloquentClientContract', function ($app) {
return new Reloquent\Test\ReloquentClientMock();
});
}
示例13: bindings
/**
* @param \Illuminate\Foundation\Application $app
* @return mixed
*/
public function bindings(\Illuminate\Foundation\Application $app)
{
$app->bind('CoandaCMS\\Coanda\\Pages\\Repositories\\PageRepositoryInterface', 'CoandaCMS\\Coanda\\Pages\\Repositories\\Eloquent\\EloquentPageRepository');
}
示例14: bindings
/**
* @param Application $app
* @return mixed
*/
public function bindings(Application $app)
{
$app->bind('CoandaCMS\\Coanda\\Media\\Repositories\\MediaRepositoryInterface', 'CoandaCMS\\Coanda\\Media\\Repositories\\Eloquent\\EloquentMediaRepository');
}
示例15: resolveApplication
/**
* Resolve application implementation.
*
* @return \Illuminate\Foundation\Application
*/
protected function resolveApplication()
{
$app = new Application($this->getBasePath());
$app->bind('Illuminate\\Foundation\\Bootstrap\\LoadConfiguration', 'Orchestra\\Testbench\\Bootstrap\\LoadConfiguration');
return $app;
}