当前位置: 首页>>代码示例>>PHP>>正文


PHP Container::offsetGet方法代码示例

本文整理汇总了PHP中Pimple\Container::offsetGet方法的典型用法代码示例。如果您正苦于以下问题:PHP Container::offsetGet方法的具体用法?PHP Container::offsetGet怎么用?PHP Container::offsetGet使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Pimple\Container的用法示例。


在下文中一共展示了Container::offsetGet方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: it_resolve_commands

 public function it_resolve_commands(Container $container, $command1, $command2)
 {
     $container->keys()->willReturn(['test1.command', 'test2.command']);
     $container->offsetGet('test1.command')->willReturn($command1);
     $container->offsetGet('test2.command')->willReturn($command2);
     $this->commands()->shouldReturn([$command1, $command2]);
 }
开发者ID:gitory,项目名称:pimple-cli,代码行数:7,代码来源:ServiceCommandResolverSpec.php

示例2: compile

 /**
  * Register the ServiceProvider in the container.
  *
  * @return Container
  */
 public function compile()
 {
     if (!$this->compiled) {
         $this->compiled = true;
         $this->container->register(new ServiceProvider(), $this->config);
         $this->container->offsetGet('console')->addCommands($this->commands);
     }
     return $this->container;
 }
开发者ID:jonsa,项目名称:pimple-console,代码行数:14,代码来源:Builder.php

示例3: __construct

 /**
  * AbstractController constructor.
  * @param Container $container
  */
 public function __construct(Container $container)
 {
     $this->container = $container;
     if ($twig = $this->container->offsetGet('twig')) {
         $this->twig = $twig;
     }
     if ($response = $this->container->offsetGet('response')) {
         $this->response = $response;
     }
     if ($request = $this->container->offsetGet('request')) {
         $this->request = $request;
     }
 }
开发者ID:neok,项目名称:TwitchPhpExample,代码行数:17,代码来源:AbstractController.php

示例4: register

 public function register(Container $container)
 {
     $cid = $this->cid;
     $container[$cid] = $container->factory(function () use($cid, $container) {
         $get = function ($key, $default = null) use($container, $cid) {
             $key = $cid . '.' . $key;
             return $container->offsetExists($key) ? $container->offsetGet($key) : $default;
         };
         $adapterName = $get('adapter');
         switch ($adapterName) {
             case 'redis':
                 $adapter = new AdapterPureRedis(['host' => $get('host'), 'port' => $get('port'), 'timeout' => $get('timeout'), 'password' => $get('password'), 'dbIndex' => $get('dbIndex')]);
                 break;
             case 'file':
                 $adapter = new AdapterFile($get('dir'));
                 break;
             default:
                 $adapter = new AdapternotCache();
                 break;
         }
         foreach ($get('options', []) as $k => $v) {
             $adapter->setOption($k, $v);
         }
         return new Cache($adapter);
     });
 }
开发者ID:okbro,项目名称:slim-cache-service,代码行数:26,代码来源:Provider.php

示例5: activateResponsiveTheme

 private function activateResponsiveTheme()
 {
     /** @var ThemeService $themeService */
     $themeService = $this->container->offsetGet('theme.service');
     $themeService->activateResponsiveTheme();
     return;
 }
开发者ID:GerDner,项目名称:luck-docker,代码行数:7,代码来源:InstallCommand.php

示例6: offsetGet

 public function offsetGet($id)
 {
     $instance = parent::offsetGet($id);
     if ($instance instanceof ContainerAware) {
         $instance->setContainer($this);
     }
     return $instance;
 }
开发者ID:sitesupra,项目名称:sitesupra,代码行数:8,代码来源:Container.php

示例7: register

 public function register(Container $app)
 {
     if ($app instanceof Application) {
         $app->error(function (\Exception $e, Request $request, $code) use($app) {
             return $app->offsetGet("error.controller")->index($e, $request, $code);
         });
     }
 }
开发者ID:Dolondro,项目名称:rargh,代码行数:8,代码来源:ErrorProvider.php

示例8: register

 public function register(Container $pimple)
 {
     if ($pimple->offsetExists('facade.aliases')) {
         $aliases = $pimple->offsetGet('facade.aliases');
     } else {
         $aliases = null;
     }
     $facadeServiceLocator = new ArrayAccessAdapter($pimple);
     FacadeLoader::init($facadeServiceLocator, $aliases);
 }
开发者ID:mrubiosan,项目名称:facade,代码行数:10,代码来源:FacadeProvider.php

示例9: it_calls_setLogger_and_processes_the_resource

 public function it_calls_setLogger_and_processes_the_resource(Container $container, Processor $processor, NodeFilter $filter)
 {
     $processor->implement(LoggerAwareInterface::class);
     $container->offsetGet('processor.default')->willReturn($processor);
     $container->offsetSet('method_filter_pattern', '/^[let|go|it_].*$/')->shouldBeCalled();
     $processor->setLogger(Argument::type(LoggerInterface::class))->shouldBeCalled();
     $processor->process(__DIR__)->shouldBeCalled();
     $stream = fopen('php://memory', 'rw');
     $this->run(new ArrayInput(['resource' => __DIR__]), new StreamOutput($stream))->shouldBe(0);
 }
开发者ID:digitalkaoz,项目名称:typehint-to-docblock,代码行数:10,代码来源:TransformCommandSpec.php

示例10: register

 public function register(Container $container)
 {
     $cid = $this->cid;
     $container[$cid] = $container->factory(function () use($cid, $container) {
         $get = function ($key, $default = null) use($container, $cid) {
             $key = $cid . '.' . $key;
             return $container->offsetExists($key) ? $container->offsetGet($key) : $default;
         };
         $pdo = new Database($get('dsn'), $get('user'), $get('password'), $get('options', []));
         return new Db($pdo);
     });
 }
开发者ID:okbro,项目名称:slim-db-service,代码行数:12,代码来源:Provider.php

示例11: make

 /**
  * @param string $abstract
  * @param array $parameters
  * @return mixed
  * @throws ContainerException
  */
 public function make($abstract, $parameters = [])
 {
     $abstract = $this->getAlias($abstract);
     $normalAbstract = $this->normalize($abstract);
     if ($this->container->offsetExists($normalAbstract)) {
         return $this->container->offsetGet($normalAbstract);
     }
     if (!class_exists($abstract)) {
         throw new ContainerException("Class {$abstract} does not exist");
     }
     $reflector = new \ReflectionClass($abstract);
     if (!$reflector->isInstantiable()) {
         throw new ContainerException("Can't instantiate this");
     }
     $constructor = $reflector->getConstructor();
     if (is_null($constructor)) {
         return new $abstract();
     }
     $parameters = $constructor->getParameters();
     $dependencies = $this->getDependencies($parameters);
     $builder = $reflector->newInstanceArgs($dependencies);
     $this->instance($normalAbstract, $builder);
     return $this->container->offsetGet($normalAbstract);
 }
开发者ID:xxstop,项目名称:bootstrap-di,代码行数:30,代码来源:Container.php

示例12: it_should_still_allow_service_subscriber_to_be_removed_after_event_has_been_triggered

 /**
  * @param MockListener          $listener
  * @param Event                 $event
  * @param Container             $container
  * @param MockServiceSubscriber $sub
  *
  * @throws \DomainException
  * @throws \InvalidArgumentException
  * @throws \LengthException
  * @throws \LogicException
  */
 public function it_should_still_allow_service_subscriber_to_be_removed_after_event_has_been_triggered(MockListener $listener, Event $event, Container $container, MockServiceSubscriber $sub)
 {
     $events = ['test1' => [[['containerID1', 'method1']]]];
     $event->hasBeenHandled()->willReturn(false);
     $sub->getServiceSubscribedEvents()->willReturn($events);
     $this->addServiceSubscriber($sub);
     $this->getServiceListeners()->shouldHaveKey('test1');
     $container->offsetGet('containerID1')->willReturn($listener);
     $this->setServiceContainer($container);
     $listener->method1($event, 'test1', $this)->shouldBeCalled();
     $this->getServiceByName('containerID1')->shouldReturn($listener);
     $this->trigger('test1', $event);
     $this->removeServiceSubscriber($sub);
     $this->getServiceListeners()->shouldNotHaveKey('test1');
 }
开发者ID:dragonrun1,项目名称:event-mediator,代码行数:26,代码来源:PimpleContainerMediatorSpec.php

示例13: Container

use Shopware\Recovery\Install\Service\ConfigWriter;
use Shopware\Recovery\Install\Service\DatabaseService;
use Shopware\Recovery\Install\Service\LicenseInstaller;
use Shopware\Recovery\Install\Service\LocaleSettingsService;
use Shopware\Recovery\Install\Service\LocalLicenseUnpackService;
use Shopware\Recovery\Install\Service\ShopService;
use Shopware\Recovery\Install\Service\CurrencyService;
use Shopware\Recovery\Install\Service\ThemeService;
use Shopware\Recovery\Install\Service\TranslationService;
use Shopware\Recovery\Install\Struct\DatabaseConnectionInformation;
use Shopware\Recovery\Install\Struct\LicenseUnpackRequest;
$config = (require __DIR__ . '/../config/production.php');
$container = new Container();
$container->register(new ContainerProvider($config));
/** @var \Slim\Slim $app */
$app = $container->offsetGet('slim.app');
// After instantiation
$sessionPath = str_replace('index.php', '', $app->request()->getScriptName());
$app->config('cookies.path', $sessionPath);
if (!isset($_SESSION)) {
    session_cache_limiter(false);
    session_set_cookie_params(600, $sessionPath);
    session_start();
}
if (!isset($_SESSION["parameters"])) {
    $_SESSION["parameters"] = [];
}
if (isset($_SESSION["databaseConnectionInfo"])) {
    $connectionInfo = $_SESSION["databaseConnectionInfo"];
    try {
        $databaseFactory = new DatabaseFactory();
开发者ID:GerDner,项目名称:luck-docker,代码行数:31,代码来源:app.php

示例14: setParameter

 /**
  * Sets a parameter.
  *
  * @param string $name  The parameter name
  * @param mixed  $value The parameter value
  *
  * @api
  */
 public function setParameter($name, $value)
 {
     $config = $this->pimple->offsetGet('config');
     $config[$name] = $value;
     $this->pimple->offsetSet('config', $config);
 }
开发者ID:GerDner,项目名称:luck-docker,代码行数:14,代码来源:Container.php

示例15: view

 protected function view($name, Config $config)
 {
     if (!($config = $config->get("views.{$name}"))) {
         throw new \LogicException("No configuration for view '{$name}'");
     }
     $view = parent::offsetGet('view')->create($config);
     parent::offsetExists('profiler') && $view->setProfiler(parent::offsetGet('profiler'));
     return $view;
 }
开发者ID:gamernetwork,项目名称:yolk-application,代码行数:9,代码来源:ServiceContainer.php


注:本文中的Pimple\Container::offsetGet方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。