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


PHP String::uuid方法代码示例

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


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

示例1: beforeSave

 public function beforeSave($options = array())
 {
     if (!isset($this->data['Comment']['id'])) {
         $this->data['Comment']['hash'] = String::uuid();
     }
     return true;
 }
开发者ID:ranostaj,项目名称:iqualJs,代码行数:7,代码来源:Comment.php

示例2: onBeforeSaveNode

 /**
  * Format data so that it can be processed by MetaBehavior for saving
  */
 public function onBeforeSaveNode(CakeEvent $event)
 {
     $data =& $event->data;
     if (isset($data['data']['SeoLite'])) {
         if (empty($data['data']['Meta'])) {
             $data['data']['Meta'] = array();
         }
         $values = array_values($data['data']['SeoLite']);
         foreach ($values as $value) {
             if (strlen($value['id']) == 36) {
                 unset($value['id']);
             }
             if (!empty($value['value'])) {
                 $data['data']['Meta'][String::uuid()] = $value;
             } else {
                 // mark empty records for deletion
                 if (isset($value['id'])) {
                     $data['delete'][] = $value['id'];
                 }
             }
         }
     }
     unset($data['data']['SeoLite']);
     return $event;
 }
开发者ID:xintesa,项目名称:seolite,代码行数:28,代码来源:SeoLiteEventHandler.php

示例3: importKeywords

 public function importKeywords()
 {
     $db = ConnectionManager::getDataSource('default');
     $mysqli = new mysqli($db->config['host'], $db->config['login'], $db->config['password'], $db->config['database']);
     $sql = array('links', 'links_keywords');
     foreach (glob('/home/kiang/public_html/news/cache/output/*.json') as $jsonFile) {
         $json = json_decode(file_get_contents($jsonFile), true);
         $newLinkId = String::uuid();
         $json['title'] = $mysqli->real_escape_string(trim($json['title']));
         $json['url'] = $mysqli->real_escape_string($json['url']);
         $json['created'] = date('Y-m-d H:i:s', $json['created_at']);
         $sql['links'][] = "('{$newLinkId}', '{$json['title']}', '{$json['url']}', '{$json['created']}')";
         foreach ($json['keywords'] as $keywordId => $summary) {
             $lkId = String::uuid();
             $summary = $mysqli->real_escape_string(trim($summary));
             $sql['links_keywords'][] = "('{$lkId}', '{$newLinkId}', '{$keywordId}', '{$summary}')";
         }
         unlink($jsonFile);
     }
     if (!empty($sql['links'])) {
         $linksSql = 'INSERT INTO links VALUES ' . implode(',', $sql['links']) . ";\n";
         $lkSql = 'INSERT INTO links_keywords VALUES ' . implode(',', $sql['links_keywords']) . ';';
         file_put_contents(TMP . 'keywords.sql', $linksSql . $lkSql);
     }
 }
开发者ID:parker00811,项目名称:elections,代码行数:25,代码来源:KeywordShell.php

示例4: __construct

 public function __construct()
 {
     foreach ($this->records as &$row) {
         $row['id'] = String::uuid();
     }
     parent::__construct();
 }
开发者ID:nodesagency,项目名称:Translations,代码行数:7,代码来源:TranslationFixture.php

示例5: beforeSave

 /**
  * Turns byte64 submitted data into files
  * 
  * @param  Model  $model
  * @param  Array $options
  * @return void
  */
 public function beforeSave(Model $model, $options = [])
 {
     foreach ($model->data[$model->alias] as $field => $value) {
         //for each result
         if (strrpos($field, 'asset_') === 0) {
             //if it's a asset field
             if (strrpos($value, 'data:') === 0) {
                 //if the asset field has byte64 data
                 $m = explode(':', $value);
                 $m = array_pop($m);
                 $r = $m = explode(';base64,', $m);
                 $m = array_shift($m);
                 $base64data = array_pop($r);
                 if (isset($this->extensionMap[$m])) {
                     $data = base64_decode($base64data);
                     $name = String::uuid() . '.' . $this->extensionMap[$m];
                     file_put_contents($this->assetFolder . DS . $name, $data);
                     $model->data[$model->alias][$field] = $name;
                 } else {
                     throw new exception('Unknow mime type (' . $m . ') for asset file, please add the mime type to the extension map');
                 }
             }
         }
     }
 }
开发者ID:sebbdk,项目名称:botcraft,代码行数:32,代码来源:AssetFileBehavior.php

示例6: beforeSave

 public function beforeSave($options = array())
 {
     if (isset($this->data['Candidate']['image']) && is_array($this->data['Candidate']['image'])) {
         if (!empty($this->data['Candidate']['image']['size'])) {
             $im = new Imagick($this->data['Candidate']['image']['tmp_name']);
             $im->resizeImage(512, 512, Imagick::FILTER_CATROM, 1, true);
             $path = WWW_ROOT . 'media';
             $fileName = str_replace('-', '/', String::uuid()) . '.jpg';
             if (!file_exists($path . '/' . dirname($fileName))) {
                 mkdir($path . '/' . dirname($fileName), 0777, true);
             }
             $im->writeImage($path . '/' . $fileName);
             if (file_exists($path . '/' . $fileName)) {
                 $this->data['Candidate']['image'] = $fileName;
             } else {
                 unset($this->data['Candidate']['image']);
             }
         } else {
             unset($this->data['Candidate']['image']);
         }
     }
     if (isset($this->data['Candidate']['name'])) {
         $this->data['Candidate']['name'] = str_replace(array('•', '•', '‧', '.', '•', '..'), '.', $this->data['Candidate']['name']);
     }
     return parent::beforeSave($options);
 }
开发者ID:parker00811,项目名称:elections,代码行数:26,代码来源:Candidate.php

示例7: after

/**
 * After migration callback
 *
 * @param string $direction, up or down direction of migration process
 * @return boolean Should process continue
 * @access public
 */
	public function after($direction) {
        if ($direction == 'up') {
            $Channel = ClassRegistry::init('Channel');
            $User = ClassRegistry::init('User');
            
            $User->create();
                    $user = $User->save(array(
                        'username' => 'test'.substr(md5(String::uuid()),0 ,5),
                        'password' => 'test1234',
                        'email' => strtolower('test').substr(md5(String::uuid()),0 ,5).'@5stars.vn',
                        'status' => 'active',
                        'role' => 'channel',
                        'fullname' => 'Test Channel'                    
                    ));
            
            $Channel->save(array(
               'id' => 100,
               'user_id' =>  $user['User']['id'],
               'status' => 'active',
               'login_connection' => 1,
               'payment_connection' => 1,
               'exchange_rate' => 1
            ));
        }
		return true;
	}
开发者ID:hungnt88,项目名称:5stars-1,代码行数:33,代码来源:1377074793_add_100_channel_for_test.php

示例8: generateAuthKey

 /**
  * Generate authorization hash.
  *
  * @return string Hash
  * @access public
  * @static
  */
 function generateAuthKey()
 {
     if (!class_exists('String')) {
         App::import('Core', 'String');
     }
     return Security::hash(String::uuid());
 }
开发者ID:cls1991,项目名称:ryzomcore,代码行数:14,代码来源:security.php

示例9: testAddWithPreSpecifiedId

/**
 * testAddWithPreSpecifiedId method
 *
 * @return void
 */
	public function testAddWithPreSpecifiedId() {
		extract($this->settings);
		$this->Tree = new $modelClass();
		$this->Tree->initialize(2, 2);

		$data = $this->Tree->find('first', array(
			'fields' => array('id'),
			'conditions' => array($modelClass . '.name' => '1.1')
		));

		$id = String::uuid();
		$this->Tree->create();
		$result = $this->Tree->save(array($modelClass => array(
			'id' => $id,
			'name' => 'testAddMiddle',
			$parentField => $data[$modelClass]['id'])
		));
		$expected = array_merge(
			array($modelClass => array('id' => $id, 'name' => 'testAddMiddle', $parentField => '2')),
			$result
		);
		$this->assertSame($expected, $result);

		$this->assertTrue($this->Tree->verify());
	}
开发者ID:hungnt88,项目名称:5stars-1,代码行数:30,代码来源:TreeBehaviorUuidTest.php

示例10: main

 function main()
 {
     if (empty($this->args)) {
         return $this->err('Usage: ./cake uuidize <table>');
     }
     if ($this->args[0] == '?') {
         return $this->out('Usage: ./cake uuidize <table> [-force] [-reindex]');
     }
     $options = array('force' => false, 'reindex' => false);
     foreach ($this->params as $key => $val) {
         foreach ($options as $name => $option) {
             if (isset($this->params[$name]) || isset($this->params['-' . $name]) || isset($this->params[$name[0]])) {
                 $options[$name] = true;
             }
         }
     }
     foreach ($this->args as $table) {
         $name = Inflector::classify($table);
         $Model = new AppModel(array('name' => $name, 'table' => $table));
         $records = $Model->find('all');
         foreach ($records as $record) {
             $Model->updateAll(array('id' => '"' . String::uuid() . '"'), array('id' => $record[$name]['id']));
         }
     }
 }
开发者ID:stripthis,项目名称:donate,代码行数:25,代码来源:uuidize.php

示例11: add

 /**
  * add method
  *
  * @return void
  */
 public function add()
 {
     if ($this->request->is('post')) {
         $this->CustomerInfo->begin();
         $this->CustomerInfo->create();
         $this->request->data['CustomerInfo']['id'] = String::uuid();
         if ($this->CustomerInfo->save($this->request->data)) {
             $this->CusRegAddr->begin();
             $this->CusRegAddr->create();
             $this->request->data['CusRegAddr']['customer_info_id'] = $this->request->data['CustomerInfo']['id'];
             if ($this->CusRegAddr->save($this->request->data)) {
                 $this->CustomerInfo->commit();
                 $this->CusRegAddr->commit();
                 $this->Session->setFlash(__('The customer information has been saved'), 'flash_success');
                 $this->redirect(array('action' => 'index'));
             } else {
                 $this->CusRegAddr->rollback();
                 $this->CustomerInfo->rollback();
             }
         } else {
             $this->CustomerInfo->rollback();
             $this->Session->setFlash(__('The customer information could not be saved. Please, try again.'), 'flash_fail');
         }
     }
     $postCodes = $this->PostCode->find('list');
     $towns = $this->Town->find('list');
     $counties = $this->County->find('list');
     $this->set(compact('postCodes', 'towns', 'counties'));
 }
开发者ID:julkar9,项目名称:gss,代码行数:34,代码来源:CustomerInfosController.php

示例12: request_id

 private function request_id()
 {
     if (empty(self::$_request_id)) {
         self::$_request_id = String::uuid();
     }
     return self::$_request_id;
 }
开发者ID:inigoflores,项目名称:CakePHP-Audit-Log-Plugin,代码行数:7,代码来源:AuditableBehavior.php

示例13: beforeSave

 public function beforeSave(Model $model)
 {
     if (empty($model->id) && $model->hasField('uuid')) {
         $model->data[$model->alias]['uuid'] = String::uuid();
     }
     return true;
 }
开发者ID:port80labs,项目名称:Boxmeup,代码行数:7,代码来源:UuidableBehavior.php

示例14: checkLogin

        public function checkLogin()
        {
            $this->autoRender = false;
            if ($this->Session->check('Test.authId')) {
                die(json_encode(array('status' => true)));
            } else {
                if ($this->Session->check('Test.token')) {
                    $result =  $this->GameApi->resource('User')->request('/checkLogin',array(
                        'method' => 'POST',
                        'data' => array(
                            'channelId' => $this->Session->read('Test.channelId'),
                            'gameId' => $this->Session->read('Test.gameId'),
                            'token' => $this->Session->read('Test.token') 
                    )));  

                    if (!empty($result['login_status']) && $result['login_status'] == 1) {
                        $this->Session->write('Test.authId',$result['userId']);                         
                        die(json_encode(array('status' => true)));
                    } else {
                        die(json_encode(array('status' => 'error')));
                    }
                } else {
                    $this->Session->write('Test.token', String::uuid());
                    die(json_encode(array('status' => 'open', 'token' => $this->Session->read('Test.token'))));
                }
            }
        }
开发者ID:hungnt88,项目名称:5stars-1,代码行数:27,代码来源:DemosController.php

示例15: main

 function main()
 {
     if (empty($this->args)) {
         return $this->err('Usage: ./cake fixturize <table>');
     }
     if ($this->args[0] == '?') {
         return $this->out('Usage: ./cake fixturize <table> [-force] [-reindex]');
     }
     $options = array('force' => false, 'reindex' => false);
     foreach ($this->params as $key => $val) {
         foreach ($options as $name => $option) {
             if (isset($this->params[$name]) || isset($this->params['-' . $name]) || isset($this->params[$name[0]])) {
                 $options[$name] = true;
             }
         }
     }
     foreach ($this->args as $table) {
         $name = Inflector::classify($table);
         $Model = new AppModel(array('name' => $name, 'table' => $table));
         $file = sprintf('%stests/fixtures/%s_fixture.php', APP, Inflector::underscore($name));
         $File = new File($file);
         if ($File->exists() && !$options['force']) {
             $this->err(sprintf('File %s already exists, use --force option.', $file));
             continue;
         }
         $records = $Model->find('all');
         $out = array();
         $out[] = '<?php';
         $out[] = '';
         $out[] = sprintf('class %sFixture extends CakeTestFixture {', $name);
         $out[] = sprintf('	var $name = \'%s\';', $name);
         $out[] = '	var $records = array(';
         $File->write(join("\n", $out));
         foreach ($records as $record) {
             $out = array();
             $out[] = '		array(';
             if ($options['reindex']) {
                 foreach (array('old_id', 'vendor_id') as $field) {
                     if ($Model->hasField($field)) {
                         $record[$name][$field] = $record[$name]['id'];
                         break;
                     }
                 }
                 $record[$name]['id'] = String::uuid();
             }
             foreach ($record[$name] as $field => $val) {
                 $out[] = sprintf('			\'%s\' => \'%s\',', addcslashes($field, "'"), addcslashes($val, "'"));
             }
             $out[] = '		),';
             $File->write(join("\n", $out));
         }
         $out = array();
         $out[] = '	);';
         $out[] = '}';
         $out[] = '';
         $out[] = '?>';
         $File->write(join("\n", $out));
         $this->out(sprintf('-> Create %sFixture with %d records (%d bytes) in "%s"', $name, count($records), $File->size(), $file));
     }
 }
开发者ID:stripthis,项目名称:donate,代码行数:60,代码来源:fixturize.php


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