本文整理汇总了PHP中Illuminate\Contracts\Container\Container::make方法的典型用法代码示例。如果您正苦于以下问题:PHP Container::make方法的具体用法?PHP Container::make怎么用?PHP Container::make使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Illuminate\Contracts\Container\Container
的用法示例。
在下文中一共展示了Container::make方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: handle
/**
* Handle the command.
*
* @param Container $container
*/
public function handle(Container $container)
{
/*
* Set the default options handler based
* on the builder class. Defaulting to
* no handler.
*/
if (!$this->builder->getRepository()) {
$model = $this->builder->getFormModel();
$entry = $this->builder->getEntry();
$form = $this->builder->getForm();
$repository = str_replace('FormBuilder', 'FormRepository', get_class($this->builder));
if (!$this->builder->getRepository() && class_exists($repository)) {
$this->builder->setRepository($container->make($repository, compact('form', 'model')));
} elseif (!$this->builder->getRepository() && $model instanceof EntryModel) {
$this->builder->setRepository($container->make(EntryFormRepository::class, compact('form', 'model')));
} elseif (!$this->builder->getRepository() && $model instanceof EloquentModel) {
$this->builder->setRepository($container->make(EloquentFormRepository::class, compact('form', 'model')));
} elseif (!$this->builder->getRepository() && $entry instanceof EntryModel) {
$this->builder->setRepository($container->make(EntryFormRepository::class, ['form' => $form, 'model' => $entry]));
} elseif (!$this->builder->getRepository() && $entry instanceof EloquentModel) {
$this->builder->setRepository($container->make(EloquentFormRepository::class, ['form' => $form, 'model' => $entry]));
}
}
}
示例2: make
/**
* Resolve the given resource name.
*
* @param string $name
* @throws \ByCedric\Allay\Exceptions\ResourceNotFoundException
* @return mixed
*/
public function make($name)
{
if ($this->contains($name)) {
return $this->container->make($this->resources[$name]);
}
throw new ResourceNotFoundException($name);
}
示例3: make
public function make($class)
{
$command = $this->container->make($class);
$command->setLaravel($this->container);
$command->setServer($this->container->make('FluxBB\\Server\\ServerInterface'));
return $command;
}
示例4: 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;
}
示例5: 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']));
}
}
示例6: 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);
}
示例7: 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));
}
示例8: getSlice
/**
* Get a Closure that represents a slice of the application onion.
*
* @return \Closure
*/
protected function getSlice()
{
return function ($stack, $middleware) {
return function ($request) use($stack, $middleware) {
return $this->container->make($middleware)->handle($request, $stack);
};
};
}
示例9: make
/**
* Make a view.
*
* @param array $parameters
* @return ViewInterface
*/
public function make(array $parameters)
{
if (!class_exists(array_get($parameters, 'view'))) {
array_set($parameters, 'view', $this->view);
}
$this->hydrator->hydrate($view = $this->container->make(array_get($parameters, 'view'), $parameters), $parameters);
return $view;
}
示例10: createDecorator
/**
* Some decorators depend on others to complete their task.
*
* This is a helper method to easily create decorators that are available.
*
* @param string $class
*
* @throws \McCool\LaravelAutoPresenter\Exceptions\DecoratorNotFound
*
* @return object
*/
public function createDecorator($class)
{
$decoratorClass = implode('\\', [__NAMESPACE__, $class . 'Decorator']);
if (!class_exists($decoratorClass)) {
throw new DecoratorNotFound($decoratorClass);
}
return $this->container->make($decoratorClass);
}
示例11: getValidatorForCommand
/**
* Retrieves the validator for a specified command
*
* @param string $commandName
* @return null|object
*/
public function getValidatorForCommand($commandName)
{
$class_name = sprintf('%sValidator', $commandName);
if (false === class_exists($class_name)) {
return null;
}
return $this->app->make($class_name);
}
示例12: resolve
/**
* Resolve the current request.
*
* @return \Bugsnag\Request\RequestInterface
*/
public function resolve()
{
if ($this->app->runningInConsole()) {
return new NullRequest();
}
$request = $this->app->make(Request::class);
return new LaravelRequest($request);
}
示例13: resolveServiceClass
/**
* Resolve a class based on the driver configuration
*
* @return \Indatus\Dispatcher\Scheduling\ScheduleService
*/
public function resolveServiceClass()
{
try {
return $this->container->make($this->getDriver() . '\\ScheduleService');
} catch (ReflectionException $e) {
return $this->container->make('Indatus\\Dispatcher\\Drivers\\' . $this->getDriver() . '\\ScheduleService');
}
}
示例14: getHandlerForCommand
/**
* Returns the handler located in the same directory for a specified command.
*
* @param string $command
* @return object
*
* @throws \League\Tactician\Exception\MissingHandlerException
*/
public function getHandlerForCommand($command)
{
$handler = substr_replace($command, 'CommandHandler', strrpos($command, 'Command'));
if (!class_exists($handler)) {
throw MissingHandlerException::forCommand($command);
}
return $this->container->make($handler);
}
示例15: requestHandler
/**
* @param $requestClass
* @return RequestHandlerInterface
*/
private function requestHandler($requestClass)
{
$handler = $this->container->make($requestClass);
if (!$handler instanceof RequestHandlerInterface) {
throw new RuntimeException("Class {$requestClass} is not a request handler.");
}
return $handler;
}