本文整理汇总了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'));
}
}
示例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);
}
}
示例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);