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


PHP Container::keys方法代码示例

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


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

示例1: commands

 public function commands()
 {
     if ($this->commands === null) {
         $this->commands = [];
         foreach ($this->container->keys() as $serviceName) {
             if (preg_match('/\\.command$/', $serviceName)) {
                 $this->commands[] = $this->container[$serviceName];
             }
         }
     }
     return $this->commands;
 }
开发者ID:gitory,项目名称:pimple-cli,代码行数:12,代码来源:ServiceCommandResolver.php

示例2: __get

 public function __get($name)
 {
     if (in_array($name, $this->container->keys())) {
         $service = $this->container[$name];
         if (is_a($service, 'Sloop\\Controller\\AbstractController')) {
             return $service->getRoute();
         } else {
             return $service;
         }
     }
     return null;
 }
开发者ID:jhnbrnn,项目名称:Sloop,代码行数:12,代码来源:Sloop.php

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

示例4: getDefinedTasks

 /**
  * @return array
  */
 protected function getDefinedTasks()
 {
     $tasks = [];
     foreach ($this->container->keys() as $key) {
         $match = [];
         if (preg_match('/^task:(.*)$/', $key, $match)) {
             $tasks[] = $match[1];
         }
     }
     return $tasks;
 }
开发者ID:lemonphp,项目名称:deploy,代码行数:14,代码来源:App.php

示例5: parseData

 /**
  * Parses the data's keys from the raw source.
  *
  * @param  Pimple|array $data The data to format.
  * @return array        The data keys.
  *
  * @SuppressWarnings(PHPMD.ElseExpression)
  */
 public static function parseData($data)
 {
     if ($data instanceof Pimple) {
         $keys = $data->keys();
     } elseif (is_array($data)) {
         $keys = array_keys($data);
     } else {
         throw new ErrorException(sprintf('Only Pimple objects or arrays can be passed to %s. [Type: %s]', __FUNCTION__, get_class($data)));
     }
     sort($keys);
     return $keys;
 }
开发者ID:skyzyx,项目名称:shared-utilities,代码行数:20,代码来源:Table.php

示例6: parseContainer

 /**
  * Generate a mapping of the container's values
  *
  * @param Container $container
  * @return array
  */
 protected function parseContainer(Container $container)
 {
     $map = array();
     foreach ($container->keys() as $name) {
         if (strpos($name, self::DIC_PREFIX) === 0) {
             continue;
         }
         if ($item = $this->parseItem($container, $name)) {
             $map[] = $item;
         }
     }
     return $map;
 }
开发者ID:skalpa,项目名称:silex-pimple-dumper,代码行数:19,代码来源:PimpleDumpProvider.php

示例7: buildTree

 protected function buildTree(Container $container)
 {
     $services = $container->keys();
     sort($services);
     $tree = [];
     foreach ($services as $service) {
         try {
             $tree[$service] = $this->describeObject($container[$service]);
         } catch (\Exception $e) {
             throw new \Exception(sprintf('An exception occurred resolving "%s": %s', $service, $e->getMessage()));
         }
     }
     return $tree;
 }
开发者ID:glynnforrest,项目名称:neptune,代码行数:14,代码来源:ServiceListCommand.php

示例8: findService

 /**
  * Procura pelo serviço no container de acordo com o parametro.
  *
  * Primeiro ele verifica se o nome do parametro já não é o nome de
  * algum serviço definido. Caso não seja encontrado, ele procura
  * em todos os serviços disponíveis do container e retorna o
  * serviço que for instância da classe type-hinteada.
  *
  * @param \ReflectionParameter $refl
  * @return mixed|null
  */
 private function findService(\ReflectionParameter $refl)
 {
     if ($refl->getClass()->name === 'Pimple\\Container' || $refl->getClass()->isSubclassOf('Pimple\\Container')) {
         return $this->container;
     }
     // Tenta procurar pelo nome do parametro
     $serviceName = $this->normalizeServiceName($refl->name);
     if (isset($this->container[$serviceName])) {
         $service = $this->container[$serviceName];
         if ($refl->getClass()->isInstance($service)) {
             return $service;
         }
     }
     // Tenta procurar em todos os serviços do container se
     // não tem algum que é instância daquela classe
     foreach ($this->container->keys() as $key) {
         $service = $this->container[$key];
         if ($refl->getClass()->isInstance($service)) {
             return $service;
         }
     }
     return null;
 }
开发者ID:brodaproject,项目名称:broda,代码行数:34,代码来源:TypeHintInjector.php

示例9: testConstructor

 /**
  * Test __construct().
  */
 public function testConstructor()
 {
     $app = new Application(['foo' => 'bar']);
     $this->assertInstanceOf(Config::class, $app['config']);
     $providers = $app->getProviders();
     foreach ($providers as $provider) {
         $container = new Container();
         $container->register(new $provider());
         $container['config'] = $app->raw('config');
         $container['access_token'] = $app->raw('access_token');
         $container['request'] = $app->raw('request');
         $container['cache'] = $app->raw('cache');
         foreach ($container->keys() as $providerName) {
             $this->assertEquals($container->raw($providerName), $app->raw($providerName));
         }
         unset($container);
     }
 }
开发者ID:edtim8,项目名称:wechat,代码行数:21,代码来源:ApplicationTest.php

示例10: keys

 public function keys()
 {
     return $this->pimpleContainer->keys();
 }
开发者ID:zwilias,项目名称:dimple,代码行数:4,代码来源:Container.php

示例11: processEnvironment

 /**
  * @param Container $container
  * @return mixed
  */
 protected function processEnvironment(Container $container)
 {
     $containerKeys = $container->keys();
     // Note: This will only set parameters IF they already exist in some form in the configuration
     foreach ($_SERVER as $key => $value) {
         if (0 === stripos($key, self::ENVIRONMENT_PREFIX)) {
             $key = substr($key, strlen(self::ENVIRONMENT_PREFIX));
             $key = str_replace("__", ".", $key);
             $key = strtolower($key);
             // Look to see if the environment variable exists purely as lowercase
             if (!$container->offsetExists($key)) {
                 // If it doesn't, then lowercase the container keys and see if we can find it there
                 if (($offsetKey = array_search(strtolower($key), array_map('strtolower', $containerKeys))) === false) {
                     // If we can't, then we shouldn't be setting this variable
                     continue;
                 }
                 // Otherwise, use the correct key
                 $key = $containerKeys[$offsetKey];
             }
             $container->offsetSet($key, $value);
         }
     }
 }
开发者ID:silktide,项目名称:syringe,代码行数:27,代码来源:ContainerBuilder.php

示例12: register

 /**
  * {@inheritdoc}
  */
 public function register(Container $pimple)
 {
     foreach ($pimple->keys() as $serviceName) {
         $pimple->extend($serviceName, $this);
     }
 }
开发者ID:spiechu,项目名称:lazy-pimple,代码行数:9,代码来源:MultiServiceAwareExtender.php

示例13: testKeys

 public function testKeys()
 {
     $pimple = new Container();
     $pimple['foo'] = 123;
     $pimple['bar'] = 123;
     $this->assertEquals(array('foo', 'bar'), $pimple->keys());
 }
开发者ID:pancke,项目名称:yyaf,代码行数:7,代码来源:PimpleTest.php

示例14: _parseContainer

 /**
  * Generate a mapping of the container's values
  * @param Container $container
  * @return array
  */
 protected function _parseContainer(Container $container)
 {
     $map = array();
     foreach ($container->keys() as $name) {
         if ($item = $this->_parseItem($container, $name)) {
             $map[] = $item;
         }
     }
     $map = $this->_normalizeMap($map);
     return $map;
 }
开发者ID:jbzoo,项目名称:pimpledumper,代码行数:16,代码来源:PimpleDumper.php

示例15: getAvailableTransports

 /**
  * Return the list of registered transports
  *
  * @access public
  * @return array
  */
 public function getAvailableTransports()
 {
     $availableTransports = $this->transports->keys();
     return array_combine($availableTransports, $availableTransports);
 }
开发者ID:renothing,项目名称:kanboard,代码行数:11,代码来源:Client.php


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