當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Uuid\Uuid類代碼示例

本文整理匯總了PHP中Ramsey\Uuid\Uuid的典型用法代碼示例。如果您正苦於以下問題:PHP Uuid類的具體用法?PHP Uuid怎麽用?PHP Uuid使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了Uuid類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: convertToDatabaseValue

 /**
  * {@inheritdoc}
  *
  * @param Uuid|null                                 $value
  * @param \Doctrine\DBAL\Platforms\AbstractPlatform $platform
  */
 public function convertToDatabaseValue($value, AbstractPlatform $platform)
 {
     if (empty($value)) {
         return null;
     }
     if ($value instanceof Uuid) {
         return $value->getBytes();
     }
     try {
         $uuid = Uuid::fromString($value);
     } catch (InvalidArgumentException $e) {
         throw ConversionException::conversionFailed($value, self::NAME);
     }
     return $uuid->getBytes();
 }
開發者ID:ramsey,項目名稱:uuid-doctrine,代碼行數:21,代碼來源:UuidBinaryType.php

示例2: save

 /**
  * Add a uuid to the model before persist to the data base.
  *
  * @param array $options
  */
 public function save(array $options = [])
 {
     if (!$this->exists) {
         $this->uuid = Uuid::uuid4();
     }
     parent::save($options);
 }
開發者ID:sahibalejandro,項目名稱:share-markdown,代碼行數:12,代碼來源:UuidField.php

示例3: handlePost

function handlePost($app, $request)
{
    // Timestamp & reverse-timestamp
    $odt = new DateTime('now', new DateTimeZone("Europe/Amsterdam"));
    $timestamp = $odt->format("Y-m-d H:i");
    $rtimestamp = $odt->format("siHdmY");
    try {
        $uuid1 = Uuid::uuid1();
        // Make sure the media file was uploaded without error
        $file = $request->files->get('mediaFile');
        if (!$file instanceof UploadedFile || $file->getError()) {
            throw new \InvalidArgumentException('The file is not valid.');
        }
        $ofilename = $rtimestamp . '-' . $file->getFilename();
        // create a thumbnail
        $image = $app['imagine']->open($file->getPathname());
        $tfilename = $rtimestamp . '-' . $file->getFilename() . '-thumb.jpeg';
        $tfilepath = $file->getPath() . '/' . $tfilename;
        $image->resize(new Box(200, 200))->save($tfilepath);
        // Upload the original media file to S3
        $ores = $app['aws.s3']->upload($app['env.orig'], $ofilename, fopen($file->getPathname(), 'r'), 'public-read');
        // upload the thumbnail
        $tres = $app['aws.s3']->upload($app['env.trans'], $tfilename, fopen($tfilepath, 'r'), 'public-read');
        // add file metadata
        $dynamoDbResult = $app['aws.ddb']->putItem(['TableName' => $app['env.table'], 'Item' => ['owner' => ['S' => 'PHP-User'], 'uid' => ['S' => $uuid1->toString()], 'timestamp' => ['S' => $timestamp], 'description' => ['S' => (string) $request->request->get('caption')], 'name' => ['S' => $file->getClientOriginalName()], 'source' => ['S' => $ofilename], 'thumbnail' => ['S' => $tfilename]]]);
        return array('type' => 'success', 'message' => 'File uploaded.');
    } catch (Exception $e) {
        // @TODO if something fails, rollback any object uploads
        return array('type' => 'error', 'message' => "Error uploading your photo:" . $e);
    }
}
開發者ID:AWSLuxGroup,項目名稱:workshop1-php,代碼行數:31,代碼來源:app.php

示例4: deserializeUuid

 public function deserializeUuid(VisitorInterface $visitor, $data, array $type, Context $context)
 {
     if (null === $data) {
         return null;
     }
     return Uuid::fromString($data);
 }
開發者ID:pauci,項目名稱:cqrs,代碼行數:7,代碼來源:RamseyUuidHandler.php

示例5: it_should_be_able_to_delete_an_object

 public function it_should_be_able_to_delete_an_object(\PDOStatement $pdoStatement)
 {
     $uuid = Uuid::uuid4();
     $this->pdo->prepare(new TypeToken('string'))->willReturn($pdoStatement);
     $pdoStatement->execute(['uuid' => $uuid->getBytes(), 'type' => 'test'])->shouldBeCalled();
     $this->delete('test', $uuid);
 }
開發者ID:jschreuder,項目名稱:SpotCms,代碼行數:7,代碼來源:ObjectRepositorySpec.php

示例6: __construct

 /**
  * Initializes a new instance of this class.
  *
  * @param string $name
  * @param string $homepage
  */
 public function __construct($name, $homepage)
 {
     $this->clientId = Uuid::uuid4();
     $this->createdOn = new DateTimeImmutable('now');
     $this->name = $name;
     $this->homepage = $homepage;
 }
開發者ID:zource,項目名稱:zource,代碼行數:13,代碼來源:OAuthApplication.php

示例7: boot

 /**
  * Boot the Uuid trait for the model.
  */
 protected static function boot()
 {
     static::creating(function ($model) {
         $model->incrementing = false;
         $model->{$model->getKeyName()} = Uuid::uuid4()->toString();
     });
 }
開發者ID:iolson,項目名稱:support,代碼行數:10,代碼來源:UuidTrait.php

示例8: send

 public function send()
 {
     if (!$this->validate()) {
         throw new SMSMessageException('Could not send message');
     }
     if (empty($this->strId)) {
         $objUuid = Uuid::uuid4();
         $this->strId = $objUuid->toString();
     }
     $arrParams = ['cc' => $this->strUsername, 'ekey' => $this->strPassword, 'message' => $this->strBody, 'title' => $this->strSenderId, 'network' => $this->strNetwork, 'value' => $this->fltValue, 'currency' => $this->strCurrency, 'encoding' => $this->strEncoding, 'number' => $this->strMsisdn, 'id' => $this->strId, 'reply' => $this->intReply];
     if ($this->blBinary) {
         $arrParams['binary'] = (int) $this->blBinary;
         $arrParams['udh'] = $this->strUdh;
     }
     if (!empty($this->shortcode)) {
         $arrParams['shortcode'] = $this->shortcode;
     }
     $this->objLogger->addDebug('Sending the following to txtNation:', $arrParams);
     $objClient = new Client(['base_uri' => 'http://client.txtnation.com/', 'timeout' => 10.0]);
     $objResponse = $objClient->get('/gateway.php', [RequestOptions::QUERY => $arrParams, RequestOptions::SYNCHRONOUS => true, RequestOptions::ALLOW_REDIRECTS => true, RequestOptions::HEADERS => ['User-agent' => 'txtNationGatewayLibraryPHP/1.0'], RequestOptions::HTTP_ERRORS => false]);
     $objResult = new SMSMessageResult($objResponse);
     $objResult->setCallbackId($this->strId);
     if (!$objResult->success()) {
         $this->objLogger->addAlert('Message was not sent. ', ['error' => $objResult->getErrorMessage()]);
     }
     return $objResult;
 }
開發者ID:saleemepoch,項目名稱:txtnation,代碼行數:27,代碼來源:Request.php

示例9: buildObject

 private function buildObject(array $data)
 {
     $data['PRODID'] = '-//Zource//Zource VObject ' . self::VERSION . '//EN';
     $data['UID'] = 'zource-vobject-' . Uuid::uuid4()->toString();
     $data['CLASS'] = 'public';
     return new VCard($data);
 }
開發者ID:zource,項目名稱:zource,代碼行數:7,代碼來源:VCardBuilder.php

示例10: testGenerate

 public function testGenerate()
 {
     $id = UuidIdentifier::generate();
     $this->assertTrue(Uuid::isValid($id));
     $uuid = Uuid::fromString($id->toString());
     $this->assertTrue($uuid->getVersion() == 4);
 }
開發者ID:gdbots,項目名稱:pbj-php,代碼行數:7,代碼來源:UuidIdentifierTest.php

示例11: __construct

 /**
  * @param mixed $payload
  * @param Metadata|array|null $metadata
  * @param UuidInterface|null $id
  */
 public function __construct($payload, $metadata = null, UuidInterface $id = null)
 {
     $this->id = $id ?: Uuid::uuid4();
     $this->payloadType = get_class($payload);
     $this->payload = $payload;
     $this->metadata = Metadata::from($metadata);
 }
開發者ID:pauci,項目名稱:cqrs,代碼行數:12,代碼來源:GenericMessage.php

示例12: onCreateArchive

 /**
  * @param ExportEventInterface $event
  * @throws CloseArchiveException
  * @throws OpenArchiveException
  * @throws UnavailableArchiveException
  */
 public function onCreateArchive(ExportEventInterface $event)
 {
     $archiveName = (string) Uuid::uuid1();
     $projectRootDir = realpath($this->projectRootDir);
     $archivePath = realpath($this->archiveDir) . '/' . $archiveName . '.zip';
     $archive = $this->openArchive($archivePath);
     foreach ($this->exportedCollection as $exportable) {
         if ($exportable instanceof ExportableInterface) {
             $exportPath = $projectRootDir . '/' . $exportable->getExportDestination();
             if (file_exists($exportPath)) {
                 $exportFile = new \SplFileObject($exportPath);
                 $archive->addFile($exportPath, $exportFile->getFilename());
             } else {
                 $this->logger->error(sprintf('Could not find export at "%s"', $exportPath));
                 // TODO Emit ErrorEvent to be handled later on for more robustness
                 continue;
             }
         }
     }
     $this->closeArchive($archive, $archivePath);
     if ($event instanceof JobAwareEventInterface) {
         if (!file_exists($archivePath)) {
             throw new UnavailableArchiveException(sprintf('Could not find archive at "%s"', $archivePath), UnavailableArchiveException::DEFAULT_CODE);
         }
         /** @var \WeavingTheWeb\Bundle\ApiBundle\Entity\Job $job */
         $job = $event->getJob();
         $archiveFile = new \SplFileObject($archivePath);
         $filename = str_replace('.zip', '', $archiveFile->getFilename());
         $router = $this->router;
         $getArchiveUrl = $this->router->generate('weaving_the_web_api_get_archive', ['filename' => $filename], $router::ABSOLUTE_PATH);
         $job->setOutput($getArchiveUrl);
     }
     $this->exportedCollection = [];
 }
開發者ID:WeavingTheWeb,項目名稱:devobs,代碼行數:40,代碼來源:ExportSubscriber.php

示例13: generate

 /**
  * {@inheritdoc}
  *
  * @return Folder
  */
 public function generate(ResourceInterface $resource = null)
 {
     $folder = new Folder();
     $folder->setId((string) Uuid::uuid4());
     $folder->setName($resource->getShortName());
     return $folder;
 }
開發者ID:api-platform,項目名稱:postman-collection-generator,代碼行數:12,代碼來源:FolderGenerator.php

示例14: getTaxList

 /**
  * 獲取稅務信息
  * @return mixed
  * @param Request $request
  * @author AndyLee <root@lostman.org>
  */
 public function getTaxList(Request $request)
 {
     $company = Company::find($request->session()->get('customer_id'));
     $start = new \DateTime($company->created_at);
     $end = new DateTime();
     $interval = DateInterval::createFromDateString('1 month');
     $period = new DatePeriod($start, $interval, $end);
     $card = [];
     foreach ($period as $dt) {
         $map = ['user_id' => $request->session()->get('company_id'), 'company_id' => $request->session()->get('customer_id'), 'flag' => $dt->format("Ym")];
         $tax = Tax::where($map)->first();
         if (empty($tax)) {
             $record = new Tax();
             $record->user_id = $request->session()->get('company_id');
             $record->company_id = $request->session()->get('customer_id');
             $record->operator_id = Auth::user()->id;
             $record->card_name = $dt->format("Ym") . '稅務申報單';
             $record->finish_time = strtotime($dt->format('Y-m') . '-15');
             $record->uuid = Uuid::uuid1();
             $record->guoshui_status = 0;
             $record->dishui_status = 0;
             $record->flag = $dt->format("Ym");
             $record->save();
             $card[] = $record->toArray();
         } else {
             $card[] = $tax->toArray();
         }
     }
     $card = array_reverse($card);
     return view('customer.tax.index')->with('cards', $card);
 }
開發者ID:n0th1n9,項目名稱:daizhang,代碼行數:37,代碼來源:TaxController.php

示例15: __construct

 public function __construct(array $state = [])
 {
     $this->metadata = [];
     $this->uuid = Uuid::uuid4()->toString();
     parent::__construct($state);
     $this->guardRequiredState();
 }
開發者ID:honeybee,項目名稱:honeybee,代碼行數:7,代碼來源:Command.php


注:本文中的Ramsey\Uuid\Uuid類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。