本文整理汇总了PHP中Illuminate\Container\Container::bound方法的典型用法代码示例。如果您正苦于以下问题:PHP Container::bound方法的具体用法?PHP Container::bound怎么用?PHP Container::bound使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Illuminate\Container\Container
的用法示例。
在下文中一共展示了Container::bound方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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());
}
}
示例2: 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));
});
}
示例3: getAdapter
/**
* @param string $name
* @param Router $router
* @return mixed
*/
public function getAdapter($name, Router $router)
{
$alias = static::CONTAINER_ADAPTER_PREFIX . $name;
$this->validateAdapter($name);
if (false === $this->container->bound($alias)) {
$this->bindAdapter($name);
}
return $this->container->make($alias, [$router]);
}
示例4: ensureIlluminateBase
/**
* Ensure the base event and file bindings are present. Required for binding anything else.
*
* @param Container $app
* @return void
*/
public function ensureIlluminateBase(Container $app = null)
{
if (!$app->bound('events')) {
$app->singleton('events', $this->illuminateClasses['events']);
$app['events']->fire('booting');
}
if (!$app->bound('files')) {
$app->bindIf('files', $this->illuminateClasses['files']);
}
}
示例5: it_should_not_affect_parent_container
/**
* @test
*/
public function it_should_not_affect_parent_container()
{
$this->parent->instance('a', 1);
$this->local->instance('a', 2);
$this->local->instance('b', 3);
$this->assertTrue($this->parent->bound('a'));
$this->assertEquals(1, $this->parent->make('a'));
$this->assertFalse($this->parent->bound('b'));
$this->assertEquals(2, $this->local->make('a'));
$this->assertEquals(3, $this->local->make('b'));
}
示例6: storeCache
/**
* Store contents in the cache.
*
* @param string $content The content to store
*
* @return bool
*/
public function storeCache($content)
{
if (!$content) {
return false;
}
// Log caching
if ($this->app->bound('log')) {
$this->app['log']->info('Caching page ' . $this->hash);
}
// Add page to cached pages
$cached = array_merge($this->getCachedPages(), [$this->hash]);
$this->app['flatten.storage']->set('cached', $cached);
return $this->app['cache']->put($this->hash, $this->formatContent($content), $this->getLifetime());
}
示例7: storeCache
/**
* Store contents in the cache
*
* @param string $content The content to store
*
* @return boolean
*/
public function storeCache($content)
{
if (!$content) {
return false;
}
// Log caching
if ($this->app->bound('log')) {
$this->app['log']->info('Caching page ' . $this->hash);
}
// Add page to cached pages
$cached = array_merge($this->getCachedPages(), array($this->hash));
$this->app['flatten.storage']->set('cached', $cached);
// Add timestamp to cache
$content .= PHP_EOL . '<!-- cached on ' . date('Y-m-d H:i:s') . ' -->';
return $this->app['cache']->put($this->hash, $content, $this->getLifetime());
}
示例8: get
/**
* Resolve the given type from the container.
*
* @param string $abstract
* @param array $parameters
*
* @throws NotFoundException
* @return mixed
*/
public function get($abstract, array $parameters = [])
{
if (!$this->delegate->bound($abstract)) {
throw NotFoundException::notBound($abstract);
}
return $this->delegate->make($abstract, $parameters);
}
示例9: findRouteMethod
/**
* Find the method of a route by its _uses or name
*
* @param string $name
*
* @return string
*/
protected function findRouteMethod($name)
{
if (!$this->app->bound('router')) {
return;
}
// Get string by name
if (!Str::contains($name, '@')) {
$routes = $this->app['router']->getRoutes();
$route = method_exists($routes, 'getByName') ? $routes->getByName($name) : $routes->get($name);
// Get string by uses
} else {
foreach ($this->app['router']->getRoutes() as $route) {
$routeUses = method_exists($route, 'getOption') ? $route->getOption('_uses') : array_get($route->getAction(), 'controller');
if ($action = $routeUses) {
if ($action == $name) {
break;
}
}
}
}
// Get method
$methods = method_exists($route, 'getMethods') ? $route->getMethods() : $route->methods();
$method = array_get($methods, 0);
return $method;
}
示例10: runRouteWithinStack
/**
* Run the given route within a Stack "onion" instance.
*
* @param \Illuminate\Routing\Route $route
* @param \Illuminate\Http\Request $request
* @return mixed
*/
protected function runRouteWithinStack(Route $route, Request $request)
{
$shouldSkipMiddleware = $this->container->bound('middleware.disable') && $this->container->make('middleware.disable') === true;
$middleware = $shouldSkipMiddleware ? [] : $this->gatherRouteMiddleware($route);
return (new Pipeline($this->container))->send($request)->through($middleware)->then(function ($request) use($route) {
return $this->prepareResponse($request, $route->run($request));
});
}
示例11: resolveController
/**
* Resolve a controller from the container.
*
* @param string $class
*
* @return \Illuminate\Routing\Controller
*/
protected function resolveController($class)
{
$controller = $this->container->make($class);
if (!$this->container->bound($class)) {
$this->container->instance($class, $controller);
}
return $controller;
}
示例12: resource
/**
* Register a resource controller.
*
* @param string $name
* @param string $controller
* @param array $options
*
* @return void
*/
public function resource($name, $controller, array $options = [])
{
if ($this->container->bound(ResourceRegistrar::class)) {
$registrar = $this->container->make(ResourceRegistrar::class);
} else {
$registrar = new ResourceRegistrar($this);
}
$registrar->register($name, $controller, $options);
}
示例13: resource
/**
* Register a resource controller.
*
* @param string $name
* @param string $controller
* @param array $options
*
* @return void
*/
public function resource($name, $controller, array $options = [])
{
if ($this->container->bound('Dingo\\Api\\Routing\\ResourceRegistrar')) {
$registrar = $this->container->make('Dingo\\Api\\Routing\\ResourceRegistrar');
} else {
$registrar = new ResourceRegistrar($this);
}
$registrar->register($name, $controller, $options);
}
示例14: resource
/**
* Route a resource to a controller.
*
* @param string $name
* @param string $controller
* @param array $options
* @return void
*/
public function resource($name, $controller, array $options = array())
{
if ($this->container && $this->container->bound('Illuminate\\Routing\\ResourceRegistrar')) {
$registrar = $this->container->make('Illuminate\\Routing\\ResourceRegistrar');
} else {
$registrar = new ResourceRegistrar($this);
}
$registrar->register($name, $controller, $options);
}
示例15: make
/**
* Resolve the given type from the container.
*
* @param string $abstract
* @param array $parameters
* @return mixed
*/
public function make($abstract, array $parameters = [])
{
if (parent::bound($abstract)) {
return parent::make($abstract, $parameters);
} elseif ($this->parentContainer->bound($abstract)) {
return $this->parentContainer->make($abstract, $parameters);
} else {
return parent::make($abstract, $parameters);
}
}