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


PHP Container::offsetExists方法代码示例

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


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

示例1: register

 /**
  * Set defaults and build the conneg service.
  *
  * @param Container $app
  * @throws ServiceUnavailableHttpException
  */
 public function register(Container $app)
 {
     $app["conneg.responseFormats"] = array("html");
     $app["conneg.requestFormats"] = array("form");
     $app["conneg.defaultFormat"] = "html";
     $app["conneg"] = function (Container $app) {
         if ($app->offsetExists("serializer")) {
             if ($app["serializer"] instanceof JMS\Serializer) {
                 if (!$app->offsetExists("conneg.serializationContext")) {
                     $app["conneg.serializationContext"] = null;
                 }
                 if (!$app->offsetExists("conneg.deserializationContext")) {
                     $app["conneg.deserializationContext"] = null;
                 }
                 return new JmsSerializerContentNegotiation($app);
             } elseif ($app["serializer"] instanceof SymfonySerializer\Serializer) {
                 if (!$app->offsetExists("conneg.serializationContext")) {
                     $app["conneg.serializationContext"] = array();
                 }
                 if (!$app->offsetExists("conneg.deserializationContext")) {
                     $app["conneg.deserializationContext"] = array();
                 }
                 return new SymfonySerializerContentNegotiation($app);
             }
         }
         throw new ServiceUnavailableHttpException(null, "No supported serializer found");
     };
 }
开发者ID:jdesrosiers,项目名称:silex-conneg-provider,代码行数:34,代码来源:ContentNegotiationServiceProvider.php

示例2: register

 /**
  * @param Container $container the dependency injection container.
  */
 public function register(Container $container)
 {
     if (!$container->offsetExists('token.length')) {
         $container['token.length'] = TokenCreator::DEFAULT_LENGTH;
     }
     if (!$container->offsetExists('token.case')) {
         $container['token.case'] = TokenCreator::UPPER;
     }
     $container['token'] = function ($container) {
         return new TokenCreator($container['token.length'], $container['token.case']);
     };
 }
开发者ID:fiedsch,项目名称:datamanagement,代码行数:15,代码来源:TokenServiceProvider.php

示例3: 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

示例4: register

 /**
  * @param Container $pimple
  */
 public function register(Container $pimple)
 {
     // Default extractor, inflector and middleware setup
     $pimple['tactician.extractor'] = new ClassNameExtractor();
     $pimple['tactician.inflector'] = new HandleInflector();
     $pimple['tactician.middleware'] = [new LockingMiddleware()];
     // Set (default tactician) locator only when not already set before
     if (!$pimple->offsetExists('tactician.locator')) {
         $pimple['tactician.locator'] = function () {
             return new InMemoryLocator();
         };
     }
     // Setup command bus
     $pimple['tactician.command_bus'] = function () use($pimple) {
         if (is_string($pimple['tactician.extractor'])) {
             $pimple['tactician.extractor'] = new $pimple['tactician.extractor']();
         }
         if (is_string($pimple['tactician.inflector'])) {
             $pimple['tactician.inflector'] = new $pimple['tactician.inflector']();
         }
         // Add handler middleware to existing set of middleware
         $middleware = $pimple['tactician.middleware'];
         $middleware[] = new CommandHandlerMiddleware($pimple['tactician.extractor'], $pimple['tactician.locator'], $pimple['tactician.inflector']);
         return new CommandBus($middleware);
     };
 }
开发者ID:jerowork,项目名称:tactician-service-provider,代码行数:29,代码来源:TacticianServiceProvider.php

示例5: register

 /**
  * @param Container|Application $app
  */
 public function register(Container $app)
 {
     if (!$app->offsetExists('annot.useServiceControllers')) {
         $app['annot.useServiceControllers'] = true;
     }
     $app["annot"] = function (Container $app) {
         return new AnnotationService($app);
     };
     // A custom auto loader for Doctrine Annotations since it can't handle PSR-4 directory structure
     AnnotationRegistry::registerLoader(function ($class) {
         return class_exists($class);
     });
     // Register ServiceControllerServiceProvider here so the user doesn't have to.
     if ($app['annot.useServiceControllers']) {
         $app->register(new ServiceControllerServiceProvider());
     }
     // this service registers the service controller and can be overridden by the user
     $app['annot.registerServiceController'] = $app->protect(function ($controllerName) use($app) {
         if ($app['annot.useServiceControllers']) {
             $app["{$controllerName}"] = function (Application $app) use($controllerName) {
                 return new $controllerName($app);
             };
         }
     });
     $app['annot.controllerFinder'] = $app->protect(function (Application $app, $dir) {
         return $app['annot']->getFiles($dir, $app['annot.controllerNamespace']);
     });
     /** @noinspection PhpUnusedParameterInspection */
     $app['annot.controller_factory'] = $app->protect(function (Application $app, $controllerName, $methodName, $separator) {
         return $controllerName . $separator . $methodName;
     });
     $app['annot.controllerNamespace'] = '';
 }
开发者ID:jsmith07,项目名称:silex-annotation-provider,代码行数:36,代码来源:AnnotationServiceProvider.php

示例6: registerResourceFactory

 /**
  * Registers new resource creator object
  *
  * @param string  $name
  * @param Closure $resourceFactory
  *
  * @return void
  * @throws DependencyException
  */
 public function registerResourceFactory($name, Closure $resourceFactory)
 {
     $key = $this->diKeys['resource'] . $name;
     if ($this->container->offsetExists($key)) {
         throw new DependencyException("Can't register resource factory with {$name}, because it's already exists");
     }
     $this->container[$key] = $resourceFactory;
 }
开发者ID:dgafka,项目名称:authorization-security,代码行数:17,代码来源:DIContainer.php

示例7: register

 /**
  * @param Container $container the dependency injection container.
  */
 public function register(Container $container)
 {
     if (!$container->offsetExists('quota.targets')) {
         $container['quota.targets'] = [];
     }
     $container['quota'] = function ($container) {
         return new QuotaCell($container['quota.targets']);
     };
 }
开发者ID:fiedsch,项目名称:datamanagement,代码行数:12,代码来源:QuotaCellServiceProvider.php

示例8: resolveService

 /**
  * {@inheritDoc}
  * @throws ReferenceException
  */
 public function resolveService($arg, Container $container, $alias = "")
 {
     if (!is_string($alias)) {
         $alias = "";
     }
     if ($arg[0] == ContainerBuilder::SERVICE_CHAR) {
         $originalName = substr($arg, 1);
         $name = $this->aliasThisKey($originalName, $alias);
         // check if the service exists
         if (!$container->offsetExists($name)) {
             $name = $originalName;
             if (!$container->offsetExists($name)) {
                 throw new ReferenceException(sprintf("Tried to inject the service '%s', but it doesn't exist", $name));
             }
         }
         $arg = $container[$name];
     }
     return $arg;
 }
开发者ID:silktide,项目名称:syringe,代码行数:23,代码来源:ReferenceResolver.php

示例9: 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

示例10: register

 /**
  * @param Container $container
  */
 public function register(Container $container)
 {
     $container->register(new ValidatorServiceProvider());
     $container["validator.mapping.class_metadata_factory"] = function () use($container) {
         $reader = new AnnotationReader();
         $loader = new AnnotationLoader($reader);
         $cache = $container->offsetExists("cache.factory") && $container["cache.factory"] instanceof Cache ? new DoctrineCache($container["cache.factory"]) : null;
         return new LazyLoadingMetadataFactory($loader, $cache);
     };
 }
开发者ID:digideskio,项目名称:singo,代码行数:13,代码来源:Validator.php

示例11: 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

示例12: route

 public function route()
 {
     if ($this->container->offsetExists('controller')) {
         $controller = $this->container['controller'];
         $controller->executeMethod();
         unset($controller);
         //Destroy all the objects
     } else {
         $view = new View\ViewNotFoundHtml($this->container['cms'], $this->container['request']->language);
         $view->renderNotFound();
     }
 }
开发者ID:netshine,项目名称:scaffold,代码行数:12,代码来源:Router.php

示例13: get

 public function get($serviceName, $resolveTags = true)
 {
     if (!$this->container instanceof Container) {
         throw new ConfigException("No Container has been set on the ServiceLocator");
     }
     if (!is_string($serviceName)) {
         throw new \InvalidArgumentException("Service name must be a string, received " . gettype($serviceName));
     }
     if (!$this->container->offsetExists($serviceName)) {
         throw new ReferenceException("The key '{$serviceName}' is not registered in this Container");
     }
     $service = $this->container[$serviceName];
     // resolve tags if required
     if ($service instanceof TagCollection && $resolveTags) {
         $services = $service->getServices();
         $service = [];
         foreach ($services as $key => $taggedService) {
             $service[$key] = $this->get($taggedService, false);
         }
     }
     return $service;
 }
开发者ID:silktide,项目名称:syringe,代码行数:22,代码来源:ServiceLocator.php

示例14: 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

示例15: register

 public function register(Container $api)
 {
     $api->extend('blimp.extend', function ($status, $api) {
         if ($status) {
             $api['security.oauth.grant.urn:blimp:accounts:google'] = function () {
                 return new Google();
             };
             if ($api->offsetExists('config.root')) {
                 $api->extend('config.root', function ($root, $api) {
                     $tb = new TreeBuilder();
                     $rootNode = $tb->root('google');
                     $rootNode->children()->scalarNode('client_id')->cannotBeEmpty()->end()->scalarNode('client_secret')->cannotBeEmpty()->end()->scalarNode('scope')->defaultValue('email https://www.googleapis.com/auth/plus.login')->end()->scalarNode('fields')->defaultValue('id,name,link,gender,email,picture')->end()->end();
                     $root->append($rootNode);
                     return $root;
                 });
             }
         }
         return $status;
     });
 }
开发者ID:blimp-php,项目名称:blimp-social-google,代码行数:20,代码来源:GoogleServiceProvider.php


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