當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。