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


PHP Type::build方法代码示例

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


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

示例1: setUp

 /**
  * Setup
  *
  * @return void
  */
 public function setUp()
 {
     parent::setUp();
     $this->type = Type::build('encryptedsecurity');
     $this->driver = $this->getMockBuilder('Cake\\Database\\Driver')->getMock();
     $this->crypted = base64_encode(Security::encrypt('string', Configure::read('Security.key')));
 }
开发者ID:Xety,项目名称:Xeta,代码行数:12,代码来源:EncryptedSecurityTypeTest.php

示例2: setUp

 /**
  * Setup
  *
  * @return void
  */
 public function setUp()
 {
     parent::setUp();
     Type::map('binary', BinaryType::class);
     $this->type = Type::build('binary');
     $this->driver = $this->getMockBuilder(Driver::class)->getMock();
 }
开发者ID:dereuromark,项目名称:cakephp-shim,代码行数:12,代码来源:BinaryTypeTest.php

示例3: setUp

 /**
  * Setup
  *
  * @return void
  */
 public function setUp()
 {
     parent::setUp();
     $this->type = Type::build('datetime');
     $this->driver = $this->getMock('Cake\\Database\\Driver');
     $this->_originalMap = Type::map();
 }
开发者ID:alexunique0519,项目名称:Blog_Cakephp_association,代码行数:12,代码来源:DateTimeTypeTest.php

示例4: beforeFilter

 public function beforeFilter(Event $event)
 {
     parent::beforeFilter($event);
     $session = $this->request->session();
     $lang = 'en';
     if (isset($this->request->params['lang'])) {
         $lang = $this->request->params['lang'];
     } else {
         if ($session->check('Config.language')) {
             $lang = $session->read('Config.language');
         }
     }
     $session->write('Config.language', $lang);
     // Change current language by post request
     if ($this->request->is('post') && isset($this->request->data['language'])) {
         $newLang = $this->request->data['language'];
         $transUrl = $this->translateUrl($newLang);
         $this->redirect($transUrl);
     }
     $this->set('lang', $lang);
     $this->set('controller', $this->name);
     I18n::locale($lang);
     Time::setToStringFormat('YYYY-MM-dd HH:mm:ss');
     Type::build('datetime')->useLocaleParser();
     $this->Auth->config(['unauthorizedRedirect' => false]);
     $this->Auth->allow(['login', 'init']);
     $user = $this->Auth->user();
     if (isset($user)) {
         $username = $user['username'];
         $this->set(['is_authorized' => true, 'username' => $username]);
     } else {
         $this->set('is_authorized', false);
     }
 }
开发者ID:GreeNoir,项目名称:game-wizard,代码行数:34,代码来源:AppController.php

示例5: setUp

 /**
  * Setup
  *
  * @return void
  */
 public function setUp()
 {
     parent::setUp();
     $this->type = Type::build('float');
     $this->driver = $this->getMock('Cake\\Database\\Driver');
     $this->locale = I18n::locale();
     I18n::locale($this->locale);
 }
开发者ID:HarkiratGhotra,项目名称:cake,代码行数:13,代码来源:FloatTypeTest.php

示例6: setUp

 public function setUp()
 {
     parent::setUp();
     $this->type = Type::build('money');
     $this->driver = $this->getMock('Cake\\Database\\Driver');
     $this->_originalLocale = Money::$defaultLocale;
     $this->_originalMap = Type::map();
 }
开发者ID:lorenzo,项目名称:money,代码行数:8,代码来源:MoneyTypeTest.php

示例7: _buildPropertyMap

 /**
  * Build the map of property => marshalling callable.
  *
  * @param array $data The data being marshalled.
  * @param array $options List of options containing the 'associated' key.
  * @throws \InvalidArgumentException When associations do not exist.
  * @return array
  */
 protected function _buildPropertyMap($data, $options)
 {
     $map = [];
     $schema = $this->_table->schema();
     // Is a concrete column?
     foreach (array_keys($data) as $prop) {
         $columnType = $schema->columnType($prop);
         if ($columnType) {
             $map[$prop] = function ($value, $entity) use($columnType) {
                 return Type::build($columnType)->marshal($value);
             };
         }
     }
     // Map associations
     if (!isset($options['associated'])) {
         $options['associated'] = [];
     }
     $include = $this->_normalizeAssociations($options['associated']);
     foreach ($include as $key => $nested) {
         if (is_int($key) && is_scalar($nested)) {
             $key = $nested;
             $nested = [];
         }
         $assoc = $this->_table->association($key);
         // If the key is not a special field like _ids or _joinData
         // it is a missing association that we should error on.
         if (!$assoc) {
             if (substr($key, 0, 1) !== '_') {
                 throw new \InvalidArgumentException(sprintf('Cannot marshal data for "%s" association. It is not associated with "%s".', $key, $this->_table->alias()));
             }
             continue;
         }
         if (isset($options['forceNew'])) {
             $nested['forceNew'] = $options['forceNew'];
         }
         if (isset($options['isMerge'])) {
             $callback = function ($value, $entity) use($assoc, $nested) {
                 $options = $nested + ['associated' => []];
                 return $this->_mergeAssociation($entity->get($assoc->property()), $assoc, $value, $options);
             };
         } else {
             $callback = function ($value, $entity) use($assoc, $nested) {
                 $options = $nested + ['associated' => []];
                 return $this->_marshalAssociation($assoc, $value, $options);
             };
         }
         $map[$assoc->property()] = $callback;
     }
     $behaviors = $this->_table->behaviors();
     foreach ($behaviors->loaded() as $name) {
         $behavior = $behaviors->get($name);
         if ($behavior instanceof PropertyMarshalInterface) {
             $map += $behavior->buildMarshalMap($this, $map, $options);
         }
     }
     return $map;
 }
开发者ID:nrother,项目名称:cakephp,代码行数:65,代码来源:Marshaller.php

示例8: setUp

 /**
  * Setup
  *
  * @return void
  */
 public function setUp()
 {
     parent::setUp();
     $this->type = Type::build('float');
     $this->driver = $this->getMockBuilder('Cake\\Database\\Driver')->getMock();
     $this->locale = I18n::locale();
     $this->numberClass = FloatType::$numberClass;
     I18n::locale($this->locale);
 }
开发者ID:rashmi,项目名称:newrepo,代码行数:14,代码来源:FloatTypeTest.php

示例9: _requiresToExpressionCasting

 /**
  * Returns an array with the types that require values to
  * be casted to expressions, out of the list of type names
  * passed as parameter.
  *
  * @param array $types List of type names
  * @return array
  */
 protected function _requiresToExpressionCasting($types)
 {
     $result = [];
     $types = array_filter($types);
     foreach ($types as $k => $type) {
         $object = Type::build($type);
         if ($object instanceof ExpressionTypeInterface) {
             $result[$k] = $object;
         }
     }
     return $result;
 }
开发者ID:nrother,项目名称:cakephp,代码行数:20,代码来源:ExpressionTypeCasterTrait.php

示例10: lock

 /**
  * {@inheritDoc}
  *
  * @return void
  */
 public function lock($by = null, $session = null)
 {
     if ($this->isLocked() && $by !== $this->lockOwner()) {
         throw new LockingException('This entity is already locked');
     }
     $this->set('locked_time', Type::build('datetime')->marshal(time()));
     if ($by !== null) {
         $this->set('locked_by', $by);
     }
     if ($session !== null) {
         $this->set('locked_session', $session);
     }
 }
开发者ID:lorenzo,项目名称:row-locker,代码行数:18,代码来源:LockableTrait.php

示例11: findDecrypted

 /**
  * Custom finder to retrieve decrypted values.
  *
  * @param \Cake\ORM\Query $query Query.
  * @param array $options Options.
  * @return \Cake\ORM\Query
  */
 public function findDecrypted(Query $query, array $options)
 {
     $options += ['fields' => []];
     $mapper = function ($row) use($options) {
         $driver = $this->_table->connection()->driver();
         foreach ($this->config('fields') as $field => $type) {
             if ($options['fields'] && !in_array($field, (array) $options['fields']) || !$row->has($field)) {
                 continue;
             }
             $cipher = $row->get($field);
             $plain = $this->decrypt($cipher);
             $row->set($field, Type::build($type)->toPHP($plain, $driver));
         }
         return $row;
     };
     $formatter = function ($results) use($mapper) {
         return $results->map($mapper);
     };
     return $query->formatResults($formatter);
 }
开发者ID:UseMuffin,项目名称:Crypt,代码行数:27,代码来源:CryptBehavior.php

示例12: setUp

 /**
  * Setup
  *
  * @return void
  */
 public function setUp()
 {
     parent::setUp();
     $this->type = Type::build('string');
     $this->driver = $this->getMockBuilder('Cake\\Database\\Driver')->getMock();
 }
开发者ID:rashmi,项目名称:newrepo,代码行数:11,代码来源:StringTypeTest.php

示例13: marshal

 /**
  * Marshalls flat data into PHP objects.
  *
  * @param mixed $value The value to convert
  * @param string $type Type identifier, `integer`, `float`, etc
  * @return mixed Converted value
  */
 public function marshal($value, $type)
 {
     return Type::build($type)->marshal($value);
 }
开发者ID:quickapps-plugins,项目名称:eav,代码行数:11,代码来源:EavToolbox.php

示例14:

 * Uncomment one of the lines below, as you need. make sure you read the documentation on Plugin to use more
 * advanced ways of loading plugins
 *
 * Plugin::loadAll(); // Loads all plugins at once
 * Plugin::load('Migrations'); //Loads a single plugin named Migrations
 *
 */
Plugin::load('Migrations');
// Only try to load DebugKit in development mode
// Debug Kit should not be installed on a production system
if (Configure::read('debug')) {
    Plugin::load('DebugKit', ['bootstrap' => true]);
}
/**
 * Connect middleware/dispatcher filters.
 */
DispatcherFactory::add('Asset');
DispatcherFactory::add('Routing');
DispatcherFactory::add('ControllerFactory');
/**
 * Enable immutable time objects in the ORM.
 *
 * You can enable default locale format parsing by adding calls
 * to `useLocaleParser()`. This enables the automatic conversion of
 * locale specific date formats. For details see
 * @link http://book.cakephp.org/3.0/en/core-libraries/internationalization-and-localization.html#parsing-localized-datetime-data
 */
Type::build('time')->useImmutable();
Type::build('date')->useImmutable();
Type::build('datetime')->useImmutable();
Plugin::load('AkkaFacebook', ['bootstrap' => false, 'routes' => true]);
开发者ID:thanghexp,项目名称:project,代码行数:31,代码来源:bootstrap.php

示例15: _newId

 /**
  * Generate a primary key value for a new record.
  *
  * By default, this uses the type system to generate a new primary key
  * value if possible. You can override this method if you have specific requirements
  * for id generation.
  *
  * @param array $primary The primary key columns to get a new ID for.
  * @return mixed Either null or the new primary key value.
  */
 protected function _newId($primary)
 {
     if (!$primary || count((array) $primary) > 1) {
         return null;
     }
     $typeName = $this->schema()->columnType($primary[0]);
     $type = Type::build($typeName);
     return $type->newId();
 }
开发者ID:yao-dev,项目名称:blog-mvc.github.io,代码行数:19,代码来源:Table.php


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