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


PHP Uuid::setFactory方法代码示例

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


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

示例1: boot

 /**
  * {@inheritdoc}
  */
 public function boot()
 {
     /*
      * Set the factory for the `Uuid` singleton.
      *
      * This will allow you to make calls directly to `Uuid` static methods
      * (`uuid1`, `uuid2`, etc.) without using the factory class directly.
      * This type of usage is not recommended as it can make testing more
      * difficult.
      */
     if ($this->container->getParameter('kherge_uuid.uuid_factory.global')) {
         Uuid::setFactory($this->container->get('kherge_uuid.uuid_factory'));
     }
 }
开发者ID:kherge,项目名称:uuid-bundle,代码行数:17,代码来源:KHerGeUuidBundle.php

示例2: execute

 /**
  * {@inheritDoc}
  *
  * @param InputInterface $input
  * @param OutputInterface $output
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $uuids = array();
     $count = filter_var($input->getOption('count'), FILTER_VALIDATE_INT, array('default' => 1, 'min_range' => 1));
     if ((bool) $input->getOption('guid') == true) {
         $features = new FeatureSet(true);
         Uuid::setFactory(new UuidFactory($features));
     }
     if ((bool) $input->getOption('comb') === true) {
         Uuid::getFactory()->setRandomGenerator(new CombGenerator(Uuid::getFactory()->getRandomGenerator(), Uuid::getFactory()->getNumberConverter()));
     }
     for ($i = 0; $i < $count; $i++) {
         $uuids[] = $this->createUuid($input->getArgument('version'), $input->getArgument('namespace'), $input->getArgument('name'));
     }
     foreach ($uuids as $uuid) {
         $output->writeln((string) $uuid);
     }
 }
开发者ID:ramsey,项目名称:uuid-console,代码行数:24,代码来源:GenerateCommand.php

示例3: ApcClassLoader

<?php

use Symfony\Component\ClassLoader\ApcClassLoader;
use Symfony\Component\HttpFoundation\Request;
use LoginCidadao\CoreBundle\Security\Compatibility\RamseyUuidFeatureSet;
$loader = (require_once __DIR__ . '/../app/bootstrap.php.cache');
// Use APC for autoloading to improve performance.
// Change 'sf2' to a unique prefix in order to prevent cache key conflicts
// with other applications also using APC.
/*
$loader = new ApcClassLoader('sf2', $loader);
$loader->register(true);
*/
require_once __DIR__ . '/../app/AppKernel.php';
//require_once __DIR__.'/../app/AppCache.php';
$kernel = new AppKernel('prod', false);
$uuidFactory = new \Ramsey\Uuid\UuidFactory(new RamseyUuidFeatureSet());
\Ramsey\Uuid\Uuid::setFactory($uuidFactory);
$generator = new \Qandidate\Stack\UuidRequestIdGenerator();
$stack = new \Qandidate\Stack\RequestId($kernel, $generator);
$kernel->loadClassCache();
//$kernel = new AppCache($kernel);
$request = Request::createFromGlobals();
$response = $stack->handle($request);
$response->send();
$kernel->terminate($request, $response);
开发者ID:redelivre,项目名称:login-cidadao,代码行数:26,代码来源:app.php


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