/**
  * 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();
 }
 /**
  * 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);
 }
Esempio n. 3
0
 /**
  * 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);
 }
 /**
  * __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;
 }
 /**
  * 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());
 }
 /**
  * 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');
     }
 }
 /**
  * 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);
 }
Esempio n. 8
0
 /**
  * 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');
     }
 }
 /**
  * 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);
 }
 /**
  * @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);
 }
Esempio n. 11
0
 /**
  * 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;
 }
Esempio n. 12
0
<?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');
}
Esempio n. 13
0
<?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');
Esempio n. 14
0
// 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');
Esempio n. 15
0
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.
 */
 /**
  * Restores Type class state
  *
  * @return void
  */
 public function tearDown()
 {
     parent::tearDown();
     Type::map($this->_originalMap);
 }
Esempio n. 17
0
<?php

use Cake\Database\Type;
Type::map('loggingJson', 'Logging\\Database\\Type\\JsonType');
Esempio n. 18
0
 /**
  * Returns the base type name for the provided column.
  * This represent the database type a more complex class is
  * based upon.
  *
  * @param string $column The column name to get the base type from
  * @return string The base type name
  */
 public function baseColumnType($column)
 {
     if (isset($this->_columns[$column]['baseType'])) {
         return $this->_columns[$column]['baseType'];
     }
     $type = $this->columnType($column);
     if ($type === null) {
         return null;
     }
     if (Type::map($type)) {
         $type = Type::build($type)->getBaseType();
     }
     return $this->_columns[$column]['baseType'] = $type;
 }
Esempio n. 19
0
<?php

/**
* Licensed under The MIT License
* For full copyright and license information, please see the LICENSE.txt
* Redistributions of files must retain the above copyright notice.
*
* @copyright     Copyright (c) Mindforce Team (http://mindforce.me)
* @link          http://mindforce.me Platform CakePHP 3 Plugin
* @since         0.0.1
* @license       http://www.opensource.org/licenses/mit-license.php MIT License
*/
use Cake\Core\Configure;
use Cake\Database\Type;
use Cake\Event\EventManager;
try {
    Configure::load('config', 'default', true);
} catch (\Exception $e) {
    //die('Unable to load Config/settings file.');
}
Type::map('json', 'Platform\\Database\\Type\\JsonType');
EventManager::instance()->attach(new Platform\Event\CoreEvent(), null, ['priority' => 1]);
Esempio n. 20
0
<?php

use Cake\Database\Type;
Type::map('money', 'Gourmet\\Money\\Database\\Type\\MoneyType');
Esempio n. 21
0
<?php

/**
 * =========================
 * DelayedJobs Plugin Config
 * =========================
 * 
 */
use Cake\Core\Configure;
$defaultConfig = ['maximum' => ['maxRetries' => 5, 'pulseTime' => 6 * 60 * 60, 'priority' => 100], 'default' => ['maxRetries' => 5], 'archive' => ['enabled' => false, 'tableName' => 'delayed_jobs_archive', 'recurring' => 'tomorrow 00:30']];
$delayedJobsConfig = Configure::read('DelayedJobs');
Configure::write('DelayedJobs', \Cake\Utility\Hash::merge($defaultConfig, $delayedJobsConfig));
\Cake\Database\Type::map('serialize', 'DelayedJobs\\Database\\Type\\SerializeType');
\DelayedJobs\RecurringJobBuilder::add(['worker' => 'DelayedJobs.Archive', 'priority' => Configure::read('maximum.priority')]);
Esempio n. 22
0
Plugin::load('AssetCompress', ['bootstrap' => true]);
Plugin::load('Schema', ['bootstrap' => true]);
Plugin::load('Api', ['bootstrap' => true, 'routes' => true]);
Plugin::load('Monitor', ['bootstrap' => true, 'routes' => true]);
Configure::write('AssetCompress.rawMode', false);
if (ENVIRONMENT === Environments::DEVELOPMENT) {
    Configure::write('AssetCompress.rawMode', true);
}
// 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]);
//     Plugin::load('CakeBootstrap3');
// }
// Datasource Type Mappings
Type::map('json', 'CkTools\\Database\\Type\\JsonType');
// Load Additional Configs
Configure::load('CkTools.countries');
/**
 * Debug Logging Helper
 *
 * @return voidauth
 */
function dlog()
{
    $args = func_get_args();
    foreach ($args as $arg) {
        if (!is_string($arg)) {
            $arg = print_r($arg, true);
        }
        \Cake\Log\Log::write('debug', print_r($arg, true));
Esempio n. 23
0
<?php

/**
 * @category Proffer
 * @package bootstrap.php
 *
 * @author David Yell <*****@*****.**>
 *
 */
namespace Proffer\config;

use Cake\Database\Type;
Type::map('proffer.file', 'Proffer\\Database\\Type\\FileType');
Esempio n. 24
0
 /**
  * @return void
  */
 public function setUp()
 {
     parent::setUp();
     Type::map('year', YearType::class);
     $this->Table = TableRegistry::get('Shim.YearTypes');
 }
Esempio n. 25
0
    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();
/**
 * Register custom database types
 */
\Cake\Database\Type::map('crypted', \ThreeCMS\Database\Type\CryptedType::class);
\Cake\Database\Type::map('json', \ThreeCMS\Database\Type\JsonType::class);
/**
 * Register custom events
 */
$event = new \ThreeCMS\Event\UserEvent();
\Cake\Event\EventManager::instance()->on($event);
$event = new \ThreeCMS\Event\SettingsEvent();
\Cake\Event\EventManager::instance()->on($event);
Esempio n. 26
0
<?php

use Cake\Database\Type;
/**
 * Load the json database type
 * @see RevisionsTable
 */
Type::map('json', 'Revisions\\Database\\Type\\JsonType');
Esempio n. 27
0
 *
 * Inflector::rules('plural', ['/^(inflect)or$/i' => '\1ables']);
 * Inflector::rules('irregular', ['red' => 'redlings']);
 * Inflector::rules('uninflected', ['dontinflectme']);
 * Inflector::rules('transliteration', ['/å/' => 'aa']);
 */
/**
 * Plugins need to be loaded manually, you can either load them one by one or all of them in a single call
 * 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
 *
 */
Type::map('json', 'App\\Database\\Type\\JsonType');
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]);
}
Plugin::load('BootstrapUI');
Plugin::load('Crud');
/**
 * Connect middleware/dispatcher filters.
 */
DispatcherFactory::add('Asset');
DispatcherFactory::add('Routing');
DispatcherFactory::add('ControllerFactory');
require __DIR__ . '/events.php';
Esempio n. 28
0
define('CORE_PATH', ROOT . 'vendor' . DS . 'cakephp' . DS . 'cakephp' . DS);
define('CAKE', CORE_PATH . 'src' . DS);
define('TESTS', ROOT . 'tests');
define('APP', ROOT . 'tests' . DS . 'test_app' . DS);
define('APP_DIR', 'test_app');
define('WEBROOT_DIR', 'webroot');
define('WWW_ROOT', APP . 'webroot' . DS);
define('TMP', ROOT . 'tmp' . DS);
define('CONFIG', APP . 'config' . DS);
define('CACHE', TMP);
define('LOGS', TMP);
$loader = new \Cake\Core\ClassLoader();
$loader->register();
$loader->addNamespace('TestApp', APP);
require_once CORE_PATH . 'config/bootstrap.php';
date_default_timezone_set('UTC');
mb_internal_encoding('UTF-8');
Configure::write('debug', false);
Configure::write('App', ['namespace' => 'TestApp', 'encoding' => 'UTF-8', 'base' => false, 'baseUrl' => false, 'dir' => 'src', 'webroot' => 'webroot', 'www_root' => APP . 'webroot', 'fullBaseUrl' => 'http://localhost', 'imageBaseUrl' => 'img/', 'jsBaseUrl' => 'js/', 'cssBaseUrl' => 'css/', 'paths' => ['plugins' => [APP . 'Plugin' . DS], 'templates' => [APP . 'Template' . DS]]]);
Cache::disable();
Log::config(['debug' => ['engine' => 'Cake\\Log\\Engine\\FileLog', 'levels' => ['notice', 'info', 'debug'], 'file' => TMP . 'debug'], 'error' => ['engine' => 'Cake\\Log\\Engine\\FileLog', 'levels' => ['warning', 'error', 'critical', 'alert', 'emergency'], 'file' => TMP . 'error']]);
// Ensure default test connection is defined
if (!getenv('db_dsn')) {
    putenv('db_dsn=sqlite:/' . TMP . 'ip_type.sqlite');
}
$config = ['url' => getenv('db_dsn'), 'timezone' => 'UTC'];
// Use the test connection for 'debug_kit' as well.
ConnectionManager::config('test', ['className' => 'Cake\\Database\\Connection', 'driver' => 'Cake\\Database\\Driver\\Sqlite', 'database' => TMP . 'ip_type.sqlite', 'encoding' => 'utf8', 'cacheMetadata' => true, 'quoteIdentifiers' => false, 'url' => getenv('db_dsn'), 'timezone' => 'UTC']);
Plugin::load('IpType', ['path' => ROOT, 'bootstrap' => false]);
Type::map('ip', 'IpType\\Database\\Type\\IpType');
Esempio n. 29
0
 /**
  * Tests clear function in conjunction with map
  *
  * @return void
  */
 public function testClear()
 {
     $map = Type::map();
     $this->assertNotEmpty($map);
     $type = Type::build('float');
     Type::clear();
     $this->assertEmpty(Type::map());
     Type::map($map);
     $this->assertEquals($map, Type::map());
     $this->assertNotSame($type, Type::build('float'));
 }
 /**
  * __construct
  *
  * @param Table $table Table.
  * @param array $config Config.
  */
 public function __construct(Table $table, array $config = [])
 {
     parent::__construct($table, $config);
     Type::map('WRUtils.File', 'WRUtils\\Database\\Type\\FileType');
     $schema = $table->schema();
     foreach ($this->getFieldList() as $field => $settings) {
         $schema->columnType($field, 'WRUtils.File');
     }
     $table->schema($schema);
     $this->_Table = $table;
     // Amazon S3 config
     $config = $this->config($field);
     $credentials = new Credentials($config['S3Key'], $config['S3Secret']);
     $options = ['region' => $config['S3Region'], 'version' => $config['S3Version'], 'http' => ['verify' => false], 'signature_version' => $config['S3SignatureVersion'], 'credentials' => $credentials];
     $this->_s3Client = new S3Client($options);
 }