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


PHP Type::map方法代码示例

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


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

示例1: 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

示例2: initialize

 /**
  * Build the behaviour
  *
  * @param array $config Passed configuration
  * @return void
  */
 public function initialize(array $config)
 {
     Type::map('proffer.file', '\\Proffer\\Database\\Type\\FileType');
     $schema = $this->_table->schema();
     foreach (array_keys($this->config()) as $field) {
         $schema->columnType($field, 'proffer.file');
     }
     $this->_table->schema($schema);
 }
开发者ID:edukondaluetg,项目名称:CakePHP3-Proffer,代码行数:15,代码来源:ProfferBehavior.php

示例3: initialize

 /**
  * Initialize hook
  *
  * @param array $config The config for this behavior.
  * @return void
  */
 public function initialize(array $config)
 {
     $this->config(Hash::normalize($config));
     Type::map('upload.file', 'Josegonzalez\\Upload\\Database\\Type\\FileType');
     $schema = $this->_table->schema();
     foreach (array_keys($this->config()) as $field) {
         $schema->columnType($field, 'upload.file');
     }
     $this->_table->schema($schema);
 }
开发者ID:jxav,项目名称:cakephp-upload,代码行数:16,代码来源:UploadBehavior.php

示例4: __construct

 /**
  * __construct
  *
  * @param Table $table Table.
  * @param array $config Config.
  */
 public function __construct(Table $table, array $config = [])
 {
     parent::__construct($table, $config);
     Type::map('Utils.File', 'Utils\\Database\\Type\\FileType');
     $schema = $table->schema();
     foreach ($this->getFieldList() as $field => $settings) {
         $schema->columnType($field, 'Utils.File');
     }
     $table->schema($schema);
     $this->_Table = $table;
 }
开发者ID:eAliwei,项目名称:cakephp-utils,代码行数:17,代码来源:UploadableBehavior.php

示例5: initialize

 /**
  * Initialize hook
  *
  * @param array $config The config for this behavior
  * @return void
  */
 public function initialize(array $config)
 {
     $this->_initializedConfig = $config;
     $this->config($config);
     Type::map('upload.file', 'Dala00\\Upload\\Database\\Type\\FileType');
     $schema = $this->_table->schema();
     foreach ($config['fields'] as $field => $settings) {
         $schema->columnType($field, 'upload.file');
     }
     $this->_table->schema($schema);
     $this->fileSystem(new DefaultFileSystem());
 }
开发者ID:dala00,项目名称:cakephp-simple-upload,代码行数:18,代码来源:UploadBehavior.php

示例6: __construct

 /**
  * Constructor
  *
  * Merges config with the default and store in the config property
  *
  * @param \Cake\ORM\Table $table The table this behavior is attached to.
  * @param array $config The config for this behavior.
  */
 public function __construct(Table $table, array $config = [])
 {
     if (isset($config['columns']) && is_string($config['columns'])) {
         $config['columns'] = [$config['columns']];
     }
     parent::__construct($table, $config);
     if (!Type::map('serialized')) {
         Type::map('serialized', 'CMS\\Database\\Type\\SerializedType');
     }
     foreach ($this->config('columns') as $column) {
         $this->_table->schema()->columnType($column, 'serialized');
     }
 }
开发者ID:quickapps-plugins,项目名称:cms,代码行数:21,代码来源:SerializableBehavior.php

示例7: initialize

 /**
  * Build the behaviour
  * @param array $config Passed configuration
  * @return void
  */
 public function initialize(array $config)
 {
     // get config
     $config = $this->_config;
     // load the file type & schema
     Type::map('unimatrix.file', '\\Unimatrix\\Utility\\Database\\Type\\FileType');
     $schema = $this->_table->schema();
     // go through each field and change the column type to our file type
     foreach ($config['fields'] as $field => $path) {
         $schema->columnType($field . $config['suffix'], 'unimatrix.file');
     }
     // update schema
     $this->_table->schema($schema);
 }
开发者ID:unimatrix,项目名称:cakephp-utility,代码行数:19,代码来源:UploadableBehavior.php

示例8: initialize

 /**
  * JsonableBehavior::initialize()
  *
  * @param array $config
  * @return void
  */
 public function initialize(array $config = [])
 {
     Type::map('array', 'Tools\\Database\\Type\\ArrayType');
     if (empty($this->_config['fields'])) {
         throw new Exception('Fields are required');
     }
     if (!is_array($this->_config['fields'])) {
         $this->_config['fields'] = (array) $this->_config['fields'];
     }
     if (!is_array($this->_config['map'])) {
         $this->_config['map'] = (array) $this->_config['map'];
     }
     if (!empty($this->_config['map']) && count($this->_config['fields']) !== count($this->_config['map'])) {
         throw new Exception('Fields and Map need to be of the same length if map is specified.');
     }
     foreach ($this->_config['fields'] as $field) {
         $this->_table->schema()->columnType($field, 'array');
     }
 }
开发者ID:alescx,项目名称:cakephp-tools,代码行数:25,代码来源:JsonableBehavior.php

示例9: initialize

 /**
  * Initialize hook
  *
  * @param array $config The config for this behavior.
  * @return void
  */
 public function initialize(array $config)
 {
     $configs = [];
     foreach ($config as $field => $settings) {
         if (is_int($field)) {
             $configs[$settings] = [];
         } else {
             $configs[$field] = $settings;
         }
     }
     $this->config($configs);
     $this->config('className', null);
     Type::map('upload.file', 'Josegonzalez\\Upload\\Database\\Type\\FileType');
     $schema = $this->_table->schema();
     foreach (array_keys($this->config()) as $field) {
         $schema->columnType($field, 'upload.file');
     }
     $this->_table->schema($schema);
 }
开发者ID:josegonzalez,项目名称:cakephp-upload,代码行数:25,代码来源:UploadBehavior.php

示例10: initialize

 /**
  * @param array $config
  * @throws \Exception
  * @return void
  */
 public function initialize(array $config = [])
 {
     if (empty($this->_config['fields'])) {
         throw new Exception('Fields are required');
     }
     if (!is_array($this->_config['fields'])) {
         $this->_config['fields'] = (array) $this->_config['fields'];
     }
     if (!is_array($this->_config['map'])) {
         $this->_config['map'] = (array) $this->_config['map'];
     }
     if (!empty($this->_config['map']) && count($this->_config['fields']) !== count($this->_config['map'])) {
         throw new Exception('Fields and Map need to be of the same length if map is specified.');
     }
     foreach ($this->_config['fields'] as $field) {
         $this->_table->schema()->columnType($field, 'array');
     }
     if ($this->_config['encodeParams']['options'] === null) {
         $options = JSON_HEX_TAG | JSON_HEX_APOS | JSON_HEX_AMP | JSON_HEX_QUOT | JSON_ERROR_INF_OR_NAN | JSON_PARTIAL_OUTPUT_ON_ERROR;
         $this->_config['encodeParams']['options'] = $options;
     }
     Type::map('array', ArrayType::class);
 }
开发者ID:dereuromark,项目名称:cakephp-tools,代码行数:28,代码来源:JsonableBehavior.php

示例11: _getTypes

 /**
  * Returns the Type classes for each of the passed fields belonging to the
  * table.
  *
  * @param \Cake\ORM\Table $table The table from which to get the schema
  * @param array $fields The fields whitelist to use for fields in the schema.
  * @return array
  */
 protected function _getTypes($table, $fields)
 {
     $types = [];
     $schema = $table->schema();
     $map = array_keys(Type::map() + ['string' => 1, 'text' => 1, 'boolean' => 1]);
     $typeMap = array_combine($map, array_map(['Cake\\Database\\Type', 'build'], $map));
     foreach (['string', 'text'] as $t) {
         if (get_class($typeMap[$t]) === 'Cake\\Database\\Type') {
             unset($typeMap[$t]);
         }
     }
     foreach (array_intersect($fields, $schema->columns()) as $col) {
         $typeName = $schema->columnType($col);
         if (isset($typeMap[$typeName])) {
             $types[$col] = $typeMap[$typeName];
         }
     }
     return $types;
 }
开发者ID:QueenCityCodeFactory,项目名称:cakephp,代码行数:27,代码来源:ResultSet.php

示例12:

<?php

use Cake\Core\Configure;
use Cake\Database\Type;
Configure::write('Muffin/Tokenize', ['lifetime' => '3 days', 'length' => 32]);
if (!Type::map('json')) {
    Type::map('json', 'Muffin\\Tokenize\\Database\\Type\\JsonType');
}
开发者ID:UseMuffin,项目名称:Tokenize,代码行数:8,代码来源:bootstrap.php

示例13:

<?php

use Cake\Core\Configure;
use Cake\Database\Type;
use Cake\Log\Log;
$className = Configure::read('Log.defaultClassName') ?: 'Cake\\Log\\Engine\\FileLog';
if (!Log::config('geo')) {
    Log::config('geo', ['className' => $className, 'path' => LOGS, 'levels' => ['debug'], 'scopes' => ['geocode'], 'file' => 'geocode']);
}
Type::map('object', 'Geo\\Database\\Type\\ObjectType');
开发者ID:dereuromark,项目名称:cakephp-geo,代码行数:10,代码来源:bootstrap.php

示例14:

// Override debug by Setting Debug
Configure::write('debug', (bool) Setting::read('App.Debug'));
// 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');
DispatcherFactory::add('Maintenance');
/**
 * 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();
Type::map('json', 'App\\Database\\Type\\JsonType');
Type::map('serialize', 'App\\Database\\Type\\SerializeType');
Plugin::load('WyriHaximus/MinifyHtml', ['bootstrap' => true]);
Plugin::load('TinyAuth');
Plugin::load('Authenticate');
Plugin::load('Search');
开发者ID:crabstudio,项目名称:app,代码行数:31,代码来源:bootstrap.php

示例15: PhpConfig

use Cake\Network\Email\Email;
use Cake\Network\Request;
use Cake\Routing\DispatcherFactory;
use Cake\Utility\Security;
use Go\Aop\Features;
use CMS\Aspect\AppAspect;
use CMS\Core\Plugin;
use CMS\Event\EventDispatcher;
/**
 * Configure default event dispatcher to use global event manager.
 */
EventDispatcher::instance()->eventManager(\Cake\Event\EventManager::instance());
/**
 * Registers custom types.
 */
Type::map('serialized', 'CMS\\Database\\Type\\SerializedType');
/**
 * Read configuration file and inject configuration into various
 * CakePHP classes.
 *
 * By default there is only one configuration file. It is often a good
 * idea to create multiple configuration files, and separate the configuration
 * that changes from configuration that does not. This makes deployment simpler.
 */
Configure::config('default', new PhpConfig(__DIR__ . DS));
/**
 * Load an environment local configuration file.
 *
 * You can use this file to provide local overrides to your
 * shared configuration.
 */
开发者ID:quickapps-plugins,项目名称:cms,代码行数:31,代码来源:bootstrap_site.php


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