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