本文整理汇总了PHP中Illuminate\Container\Container类的典型用法代码示例。如果您正苦于以下问题:PHP Container类的具体用法?PHP Container怎么用?PHP Container使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Container类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getContainer
/**
* Get the IoC Container
*
* @param string $make A dependency to fetch
*
* @return Container
*/
public static function getContainer($make = null)
{
if ($make) {
return static::$container->make($make);
}
return static::$container;
}
示例2: register
/**
* Bind additional classes to the Container
*
* @param Container $app
*
* @return void
*/
public function register(Container $app)
{
$app->bind('newrelic', function ($app) {
return new RocketeerNewrelicConfig($app['config']->get('rocketeer-newrelic::config'));
});
return $app;
}
示例3: make
public function make(RequestContainer $requestContainer, Container $app)
{
if ($requestContainer->getId()) {
return new InstanceQuery($app->make('query_builders'), $requestContainer);
}
return new CollectionQuery($app->make('query_builders'), $requestContainer);
}
示例4: createApplicationContainer
protected function createApplicationContainer()
{
$this->app = new \TestContainer();
$this->app->singleton('config', function () {
return new \Illuminate\Config\Repository();
});
$this->registerConfigure();
$eventServiceProvider = new \Illuminate\Encryption\EncryptionServiceProvider($this->app);
$eventServiceProvider->register();
$eventServiceProvider = new \Illuminate\Events\EventServiceProvider($this->app);
$eventServiceProvider->register();
$queueProvider = new \Illuminate\Queue\QueueServiceProvider($this->app);
$queueProvider->register();
$sessionProvider = new \Illuminate\Session\SessionServiceProvider($this->app);
$sessionProvider->register();
$this->registerDatabase();
$this->registerCache();
$couchbaseProvider = new \Ytake\LaravelCouchbase\CouchbaseServiceProvider($this->app);
$couchbaseProvider->register();
$couchbaseProvider->boot();
$this->app->bind(\Illuminate\Container\Container::class, function () {
return $this->app;
});
(new \Illuminate\Events\EventServiceProvider($this->app))->register();
\Illuminate\Container\Container::setInstance($this->app);
}
示例5: register
/**
* Bind additional classes to the Container
*
* @param Container $app
*
* @return void
*/
public function register(Container $app)
{
$app->bind('slack', function ($app) {
return new Client($app['config']->get('rocketeer-slack::url'));
});
return $app;
}
示例6: setupContainer
/**
* Setup the IoC container instance.
*
* @param \Illuminate\Container\Container|null $container
* @return void
*/
protected function setupContainer($container)
{
$this->container = $container ?: new Container();
if (!$this->container->bound('config')) {
$this->container->instance('config', new Fluent());
}
}
示例7: register
/**
* Bind additional classes to the Container
*
* @param Container $app
*
* @return void
*/
public function register(Container $app)
{
$app->bind('campfire', function ($app) {
return new Campfire($app['config']->get('rocketeer-campfire::config'));
});
return $app;
}
示例8: setupServiceProvider
/**
* @param Container $app
*
* @return AwsServiceProvider
*/
private function setupServiceProvider(Container $app)
{
// Create and register the provider.
$provider = new AwsServiceProvider($app);
$app->register($provider);
$provider->boot();
return $provider;
}
示例9: getContainer
/**
* @return \Illuminate\Container\Container
*/
public static function getContainer()
{
if (!self::$container) {
self::$container = new \Illuminate\Container\Container();
self::$container->bind('app', self::$container);
}
return self::$container;
}
示例10: createContainer
/**
* @return ContainerInterface
*/
private function createContainer(array $map = [])
{
$container = new Container();
foreach ($map as $key => $value) {
$container->bind($key, $value);
}
return new LaravelContainer($container);
}
示例11: register
public function register(Container $app)
{
$settings = ['username' => $app['config']->get('rocketeer-slack-unofficial::config')['url'], 'channel' => $app['config']->get('rocketeer-slack-unofficial::config')['channel'], 'link_names' => true, 'icon' => ':rocket:'];
$app->bind('slack', function ($app) use($settings) {
return new Client($app['config']->get('rocketeer-slack-unofficial::config')['hook-url'], $settings);
});
return $app;
}
示例12: __construct
/**
* 初始化,注入container
*
* @param Container $container
*/
public function __construct(Container $container)
{
$this->container = $container;
// 初始化 DB类 TODO 应该用 事件监听的方式来初始化 因为有可能在不需要db的情况下也初始化了
$container->make('db');
if (method_exists($this, '__init__')) {
return call_user_func_array(array($this, '__init__'), array());
}
}
示例13: passesAuthorization
/**
* Deteremine if the request passes the authorization check.
*
* @return bool
*/
protected function passesAuthorization()
{
if (method_exists($this, 'authorize')) {
return $this->container->call([$this, 'authorize']);
}
return false;
}
示例14: driver
/**
* Changes the set SMS driver
*
* @param $driver
*/
public function driver($driver)
{
$this->container['sms.sender'] = $this->container->share(function ($app) use($driver) {
return (new DriverManager($app))->driver($driver);
});
$this->driver = $this->container['sms.sender'];
}
示例15: call
/**
* Call the given seeder.
*
* @param \Closure|string $seeder
* @return void
*/
protected function call($seeder)
{
if ($seeder instanceof Closure) {
return $this->container->call($seeder);
}
$this->container->call($seeder, [], 'seed');
}