本文整理汇总了PHP中Illuminate\Container\Container::make方法的典型用法代码示例。如果您正苦于以下问题:PHP Container::make方法的具体用法?PHP Container::make怎么用?PHP Container::make使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Illuminate\Container\Container
的用法示例。
在下文中一共展示了Container::make方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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);
}
示例2: 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;
}
示例3: getValidatorInstance
/**
* Get the validator instance for the request.
*
* @param array $rules
* @param array $messages
* @param array $customAttributes
* @return Validator
*/
protected function getValidatorInstance(array $rules, array $messages = array(), array $customAttributes = array())
{
$factory = $this->app->make('Illuminate\\Contracts\\Validation\\Factory');
$validator = $factory->make([], $rules, $messages, $customAttributes);
$validator->addCustomAttributes($customAttributes);
return $validator;
}
示例4: __construct
/**
* ExtensionRegistrar constructor.
*/
public function __construct()
{
$this->container = $this->getContainer();
$this->events = $this->container->make('events');
$this->router = $this->container->make('router');
$this->setting = $this->container->make('setting');
}
示例5: execute
/**
* Execute the required command against the command handler.
*
* @param Command $command
* @return mixed
*/
public function execute(Command $command)
{
$handler = $this->commandTranslator->getCommandHandler($command);
$commandName = $this->getCommandName($command);
$this->log->info("New command [{$commandName}]", get_object_vars($command));
return $this->app->make($handler)->handle($command);
}
示例6: makeProvidersCollection
/**
* @param array $keys
* @return \LW\Statistics\StatisticsProviderCollection
*/
protected function makeProvidersCollection($keys)
{
$collection = new StatisticsProviderCollection();
foreach ($keys as $name) {
$collection->add($name, $this->container->make($this->providerMap[$name]));
}
return $collection;
}
示例7: makeModel
/**
* Refresh modal object.
*
* @throws RepositoryException
*
* @return Model
*/
public function makeModel()
{
$model = $this->app->make($this->model());
if (!$model instanceof Model) {
throw new RepositoryException("Class {$this->model()} must be an instance of Illuminate\\Database\\Eloquent\\Model");
}
return $this->model = $model;
}
示例8: callWithinStack
/**
* Call the given controller instance method.
*
* @param \Illuminate\Routing\Controller $instance
* @param \Illuminate\Routing\Route $route
* @param \Illuminate\Http\Request $request
* @param string $method
* @return mixed
*/
protected function callWithinStack($instance, $route, $request, $method)
{
$middleware = $this->getMiddleware($instance, $method);
$shouldSkipMiddleware = $this->container->bound('middleware.disable') && $this->container->make('middleware.disable') === true;
return (new Pipeline($this->container))->send($request)->through($shouldSkipMiddleware ? [] : $middleware)->then(function ($request) use($instance, $route, $method) {
return $this->router->prepareResponse($request, $this->call($instance, $route, $method));
});
}
示例9: getValidatorInstance
/**
* Get the validator instance for the request.
*
* @return \Illuminate\Contracts\Validation\Validator
*/
protected function getValidatorInstance()
{
$factory = $this->container->make(ValidationFactory::class);
if (method_exists($this, 'validator')) {
return $this->container->call([$this, 'validator'], compact('factory'));
}
return $factory->make($this->all(), $this->container->call([$this, 'rules']), $this->messages(), $this->attributes());
}
示例10: getValidatorInstance
/**
* Get the validator instance for the request.
*
* @return \Illuminate\Validation\Validator
*/
protected function getValidatorInstance()
{
$factory = $this->container->make('Illuminate\\Validation\\Factory');
if (method_exists($this, 'validator')) {
return $this->container->call([$this, 'validator'], compact('factory'));
}
return $factory->make($this->all(), $this->container->call([$this, 'rules']), $this->messages());
}
示例11: makeCriteria
/**
* @param $class
* @param array $args
* @return mixed
* @throws RepositoryException
*/
protected function makeCriteria($class, array $args)
{
$criteria = $this->app->make($class, $args);
if (!$criteria instanceof CriteriaContract) {
throw new RepositoryException("Class {$class} must be an instance of GuilhermeGonzaga\\Repository\\Criteria\\Criteria");
}
return $criteria;
}
示例12: parseIncludes
/**
* @return $this
*/
protected function parseIncludes()
{
$request = $this->application->make('Illuminate\\Http\\Request');
$paramIncludes = Config::get('reloquent.fractal.params.include', 'include');
if ($request->has($paramIncludes)) {
$this->fractal->parseIncludes($request->get($paramIncludes));
}
return $this;
}
示例13: __construct
/**
* Constructor.
*
* @param array $viewPaths
* @param string $cachePath
* @param Container $container
*/
public function __construct($viewPaths, $cachePath, ContainerInterface $container = null)
{
$this->viewPaths = $viewPaths;
$this->cachePath = $cachePath;
$this->container = $container ?: new Container();
$this->setupContainer();
(new ViewServiceProvider($this->container))->register();
$this->engineResolver = $this->container->make('view.engine.resolver');
}
示例14: resolve
/**
* Resolve an instance of the given seeder class.
*
* @param string $class
* @return \Illuminate\Database\Seeder
*/
protected function resolve($class)
{
if (isset($this->container)) {
$instance = $this->container->make($class);
return $instance->setContainer($this->container)->setCommand($this->command);
} else {
return new $class();
}
}
示例15: it_should_auto_inject_dependencies_from_parent_container
/**
* @test
*/
public function it_should_auto_inject_dependencies_from_parent_container()
{
$this->parent->singleton(Helper::class, function () {
return new Helper(uniqid());
});
/** @var Service $service */
$service = $this->local->make(Service::class);
$this->assertInstanceOf(Service::class, $service);
$this->assertEquals($this->parent->make(Helper::class)->key, $service->helper->key);
}