本文整理汇总了PHP中Illuminate\Contracts\Container\Container类的典型用法代码示例。如果您正苦于以下问题:PHP Container类的具体用法?PHP Container怎么用?PHP Container使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Container类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: resolve
/**
* Add a command, resolving through the application.
*
* @param string $command
*
* @return \Symfony\Component\Console\Command\Command
*/
public function resolve($command)
{
if (is_null($this->container)) {
$this->container = Container::getInstance();
}
return $this->add($this->container->make($command));
}
开发者ID:notadd,项目名称:framework,代码行数:14,代码来源:Application.php
示例2: handle
/**
* Handle the command.
*
* @param ModuleCollection $modules
* @param Decorator $decorator
* @param Repository $config
* @param Container $container
* @param Request $request
* @param Search $search
* @return LengthAwarePaginator
*/
public function handle(ModuleCollection $modules, Decorator $decorator, Repository $config, Container $container, Request $request, Search $search)
{
/* @var Query $query */
$query = $search->index($this->criteria->option('index', 'default'));
$constraint = $this->criteria->option('in');
if (!empty($constraint) && is_string($constraint)) {
$query = $query->search('stream', $constraint, ['required' => true]);
}
if (!empty($constraint) && is_array($constraint)) {
/* @var Module $module */
foreach ($modules->withConfig('search') as $module) {
foreach ($config->get($module->getNamespace('search')) as $model => $definition) {
/* @var EntryInterface $model */
$model = $container->make($model);
$stream = $model->getStreamNamespace() . '.' . $model->getStreamSlug();
if (!in_array($stream, $constraint)) {
$query = $query->search('stream', $stream, ['required' => false, 'prohibited' => true]);
}
}
}
}
foreach ($this->criteria->getOperations() as $operation) {
$query = call_user_func_array([$query, $operation['name']], $operation['arguments']);
}
$page = $request->get('page', 1);
$perPage = $this->criteria->option('paginate', $this->criteria->option('limit', 15));
$query->limit($perPage, ($page - 1) * $perPage);
$collection = new SearchCollection(array_map(function ($result) use($decorator) {
return $decorator->decorate(new SearchItem($result));
}, $query->get()));
return (new LengthAwarePaginator($collection, $query->count(), $perPage, $page))->setPath($request->path())->appends($request->all());
}
开发者ID:Wol,项目名称:search-module,代码行数:43,代码来源:GetSearchResults.php
示例3: registerContainerBindings
/**
* Registers container bindings.
*
* @param Container $container
* @param ConfigRepository $config
*/
protected function registerContainerBindings(Container $container, ConfigRepository $config)
{
$container->singleton('Doctrine\\ORM\\EntityManager', function () use($config) {
return $this->createEntityManager($config);
});
$container->alias('Doctrine\\ORM\\EntityManager', 'Doctrine\\ORM\\EntityManagerInterface');
}
开发者ID:jaschweder,项目名称:lumen-doctrine,代码行数:13,代码来源:DoctrineServiceProvider.php
示例4: register
public function register(Container $container)
{
$container->singleton(Container::class, function () use($container) {
return $container;
});
$container->singleton(ContainerInterface::class, LaravelContainer::class);
}
开发者ID:simensen,项目名称:monii-nimble-framework,代码行数:7,代码来源:ContainerServiceProvider.php
示例5: registerBindings
/**
* @param Container $container
* @param ConfigRepository $config
*/
protected function registerBindings(Container $container, ConfigRepository $config)
{
$container->singleton(SparkPostService::class, function () use($config) {
return new SparkPostService($config[self::CONFIG_KEY]);
});
$container->alias(SparkPostService::class, SparkPostServiceContract::class);
}
开发者ID:nordsoftware,项目名称:lumen-sparkpost,代码行数:11,代码来源:SparkPostServiceProvider.php
示例6: __construct
/**
* Create a new Grid instance.
*
* @param \Illuminate\Contracts\Container\Container $app
*/
public function __construct(Container $app)
{
$this->app = $app;
if (method_exists($this, 'initiate')) {
$app->call([$this, 'initiate']);
}
}
开发者ID:stevebauman,项目名称:html,代码行数:12,代码来源:Grid.php
示例7: handle
/**
* Execute the console command.
* @param Container The service container.
* @return mixed
*/
public function handle(Container $services)
{
$config = config('rest-scaffolding');
$namespace = $this->argument('namespace');
$prefix = $this->argument('prefix');
$services->make(Generator::class)->setProgressBar($this->output->createProgressBar())->processFiles($config, $namespace, $prefix);
}
开发者ID:b3nl,项目名称:laravel-rest-scaffolding,代码行数:12,代码来源:MakeRest.php
示例8: registerContainerBindings
/**
* Registers the container bindings.
*
* @param Container $container
*/
protected function registerContainerBindings(Container $container)
{
$container->singleton('Nord\\Lumen\\Mandrill\\Mailer\\Contracts\\MandrillMailer', function () {
$config = config('mandrillmailer', []);
return new MandrillMailer($config);
});
}
开发者ID:nordsoftware,项目名称:lumen-mandrill-mailer,代码行数:12,代码来源:MandrillMailServiceProvider.php
示例9: registerContainerBindings
/**
* Registers container bindings.
*
* @param Container $container
* @param ConfigRepository $config
*
* @return DocumentManager
*/
protected function registerContainerBindings(Container $container, ConfigRepository $config)
{
$container->singleton('Doctrine\\ODM\\MongoDB\\DocumentManager', function () use($config) {
Config::mergeWith($config);
return $this->createDocumentManager($config);
});
}
开发者ID:nordsoftware,项目名称:lumen-doctrine-mongodb-odm,代码行数:15,代码来源:DoctrineServiceProvider.php
示例10: setupContainer
/**
* Setup the IoC container instance.
*
* @param \Illuminate\Contracts\Container\Container $container
* @return void
*/
protected function setupContainer(Container $container)
{
$this->container = $container;
if (!$this->container->bound('config')) {
$this->container->instance('config', new Fluent());
}
}
开发者ID:Vinelab,项目名称:neoeloquent-support,代码行数:13,代码来源:CapsuleManagerTrait.php
示例11: makeAndRegisterServiceProviders
protected function makeAndRegisterServiceProviders(Container $container, array $serviceProviderClassNames)
{
foreach ($serviceProviderClassNames as $providerClassName) {
$provider = $container->make($providerClassName);
$provider->register($container);
}
}
开发者ID:simensen,项目名称:monii-nimble-framework,代码行数:7,代码来源:App.php
示例12: handle
/**
* Handle the command.
*/
public function handle(Image $image, Container $container, Application $application)
{
$image->addPath('public', base_path('public'));
$image->addPath('node', base_path('node_modules'));
$image->addPath('asset', $application->getAssetsPath());
$image->addPath('streams', $container->make('streams.path') . '/resources');
$image->addPath('bower', $container->make('path.base') . '/bin/bower_components');
}
开发者ID:jacksun101,项目名称:streams-platform,代码行数:11,代码来源:AddImageNamespaces.php
示例13: send
/**
* Execute the given API action class, pass the input and return its response.
*
* @param User $actor
* @param string $actionClass
* @param array $input
* @return object
*/
public function send(User $actor, $actionClass, array $input = [])
{
/** @var \Flarum\Api\Actions\JsonApiAction $action */
$action = $this->container->make($actionClass);
$response = $action->handle(new Request($input, $actor));
return new Response($response);
}
开发者ID:huytd,项目名称:core,代码行数:15,代码来源:Client.php
示例14: boot
public function boot()
{
parent::boot();
if (!$this->container->bound(JobSchedulerInterface::class)) {
throw new CoreException('This module requires the Jobs component to be loaded. ' . 'Please make sure that `JobsServiceProvider` ' . 'is in your application\'s `config/app.php` file.');
}
}
开发者ID:MarkVaughn,项目名称:illuminated,代码行数:7,代码来源:JobsModule.php
示例15: versionFactoryExpectations
/**
* @param App $app
* @param \LaraPackage\Api\Contracts\Request\Parser $requestParser
* @param \LaraPackage\Api\Contracts\Factory\VersionFactory $versionFactory
*/
protected function versionFactoryExpectations(App $app, \LaraPackage\Api\Contracts\Request\Parser $requestParser, \LaraPackage\Api\Contracts\Factory\VersionFactory $versionFactory, ApiVersion $apiVersion)
{
$requestParser->version()->shouldBeCalled()->willReturn($this->version);
$apiVersion->factory($this->version)->shouldBeCalled()->willReturn(VersionFactory::class);
$app->instance(\LaraPackage\Api\Contracts\Factory\VersionFactory::class, $versionFactory)->shouldBeCalled();
$app->make(VersionFactory::class)->shouldBeCalledTimes(1)->willReturn($versionFactory);
}
开发者ID:larapackage,项目名称:api,代码行数:12,代码来源:FactorySpec.php
示例16: failed
/**
* Call the failed method on the job instance.
*
* @param array $data
* @return void
*/
public function failed(array $data)
{
$handler = $this->container->make($data['class']);
if (method_exists($handler, 'failed')) {
call_user_func_array([$handler, 'failed'], unserialize($data['data']));
}
}
开发者ID:scrobot,项目名称:Lumen,代码行数:13,代码来源:CallQueuedHandler.php
示例17: getConverterFor
/**
* Get the appropriate converter name for the given value.
* TODO: Clean this up. A lot.
*
* @param mixed $value
* @param bool $debug
* @return string
*/
public function getConverterFor($value, bool $debug = false)
{
$type = $this->getType($value);
$config = app('Illuminate\\Contracts\\Config\\Repository');
$defaults = collect($this->converterManager->getDefaultConverters())->merge($this->application['config']->get('laravel-xml.converters.defaults'))->filter(function ($item) {
$item = is_array($item) ? $item['value'] : $item;
return class_exists($item) or $this->container->bound($item);
});
$custom = collect($this->application['config']->get('laravel-xml.converters.custom'))->filter(function ($item) {
$item = is_array($item) ? $item['value'] : $item;
return class_exists($item) or $this->container->bound($item);
});
// if ($debug) dd($custom);
// Step one: Try to find the CLASS or TYPE in $custom
$class = $custom->get(is_object($value) ? get_class($value) : str_plural($type), function () use($custom, $defaults, $value, $type) {
// Step two: try to find the TYPE in $custom
return $custom->get(str_plural($type), function () use($defaults, $value, $type) {
// Step three: Try to find the CLASS or TYPE in $defaults
return $defaults->get(is_object($value) ? get_class($value) : str_plural($type), function () use($defaults, $value, $type) {
// Step four: Try to find the TYPE in $defaults
return $defaults->get(str_plural($type), function () {
// If nothing works, throw an error.
throw new NoConverterFoundException("Could not find an appropriate converter.");
});
});
});
});
return is_array($class) ? isset($class['value']) ? $class['value'] : '' : $class;
}
开发者ID:fetchleo,项目名称:laravel-xml,代码行数:37,代码来源:Xml.php
示例18: make
public function make($class)
{
$command = $this->container->make($class);
$command->setLaravel($this->container);
$command->setServer($this->container->make('FluxBB\\Server\\ServerInterface'));
return $command;
}
开发者ID:fluxbb,项目名称:core,代码行数:7,代码来源:CommandFactory.php
示例19: add
/**
* @param string $class
* @param int $priority
* @return Storage
*/
public function add($class, $priority = self::PRIORITY_DEFAULT) : Storage
{
$this->container->bind($class, $class);
$instance = $this->container->make($class);
$this->storage->insert($instance, $priority);
return $this;
}
开发者ID:Dualse,项目名称:GitterBot,代码行数:12,代码来源:Storage.php
示例20: handle
/**
* Handle the filter.
*
* @param Builder $query
* @param FieldFilterInterface $filter
* @param TableBuilder $builder
*/
public function handle(Builder $query, FieldFilterInterface $filter, TableBuilder $builder)
{
$stream = $filter->getStream();
$fieldType = $stream->getFieldType($filter->getField());
$fieldTypeQuery = $fieldType->getQuery();
$this->container->call([$fieldTypeQuery, 'filter'], compact('query', 'filter', 'builder'));
}
开发者ID:jacksun101,项目名称:streams-platform,代码行数:14,代码来源:FieldFilterQuery.php
注:本文中的Illuminate\Contracts\Container\Container类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论