<commit_before><?php

namespace Croogo\Croogo\Config;

use Croogo\Cache\CroogoCache;
use Croogo\Configure\CroogoJsonReader;
use Croogo\Lib\CroogoStatus;
use Extensions\Lib\CroogoPlugin;
/**
 * Default Acl plugin.  Custom Acl plugin should override this value.
 */
Configure::write('Site.acl_plugin', 'Acl');

/**
 * Default API Route Prefix. This can be overriden in settings.
 */
Configure::write('Croogo.Api.path', 'api');

/**
 * Admin theme
 */
//Configure::write('Site.admin_theme', 'sample');

/**
 * Cache configuration
 */
$defaultEngine = Configure::read('Cache.defaultEngine');
$defaultPrefix = Configure::read('Cache.defaultPrefix');
$cacheConfig = array(
	'duration' => '+1 hour',
	'path' => CACHE . 'queries' . DS,
	'engine' => $defaultEngine,
	'prefix' => $defaultPrefix,
);
Configure::write('Cache.defaultConfig', $cacheConfig);

/**
 * Settings
 */
Configure::config('settings', new CroogoJsonReader());
if (file_exists(APP . 'Config' . DS . 'settings.json')) {
	Configure::load('settings', 'settings');
}

/**
 * Locale
 */
Configure::write('Config.language', Configure::read('Site.locale'));

/**
 * Assets
 */
if (Configure::check('Site.asset_timestamp')) {
	$timestamp = Configure::read('Site.asset_timestamp');
	Configure::write(
		'Asset.timestamp',
		is_numeric($timestamp) ? (bool) $timestamp : $timestamp
	);
	unset($timestamp);
}

/**
 * Extensions
 */
Plugin::load(array('Extensions'), array('bootstrap' => true, 'routes' => true));
Configure::load('Extensions.events');

/**
 * Setup custom paths
 */
$croogoPath = Plugin::path('Croogo');
App::build(array(
	'Console/Command' => array($croogoPath . 'Console' . DS . 'Command' . DS),
	'View' => array($croogoPath . 'View' . DS),
	'View/Helper' => array($croogoPath . 'View' . DS . 'Helper' . DS),
), App::APPEND);
if ($theme = Configure::read('Site.theme')) {
	App::build(array(
		'View/Helper' => array(App::themePath($theme) . 'Helper' . DS),
	));
}

/**
 * List of core plugins
 */
Configure::write('Core.corePlugins', array(
	'Settings', 'Acl', 'Blocks', 'Comments', 'Contacts', 'Menus', 'Meta',
	'Nodes', 'Taxonomy', 'Users',
));

/**
 * Plugins
 */
$aclPlugin = Configure::read('Site.acl_plugin');
$pluginBootstraps = Configure::read('Hook.bootstraps');
$plugins = array_filter(explode(',', $pluginBootstraps));

if (!in_array($aclPlugin, $plugins)) {
	$plugins = Hash::merge((array)$aclPlugin, $plugins);
}
foreach ($plugins as $plugin) {
	$pluginName = Inflector::camelize($plugin);
	$pluginPath = APP . 'Plugin' . DS . $pluginName;
	if (!file_exists($pluginPath)) {
		$pluginFound = false;
		foreach (App::path('Plugin') as $path) {
			if (is_dir($path . $pluginName)) {
				$pluginFound = true;
				break;
			}
		}
		if (!$pluginFound) {
			Log::error('Plugin not found during bootstrap: ' . $pluginName);
			continue;
		}
	}
	$option = array(
		$pluginName => array(
			'bootstrap' => true,
			'routes' => true,
			'ignoreMissing' => true,
		)
	);
	CroogoPlugin::load($option);
}
CroogoEventManager::loadListeners();
Croogo::dispatchEvent('Croogo.bootstrapComplete');<commit_msg>Upgrade croogo_bootstrap.php for cakephp 3.x<commit_after><?php

namespace Croogo\Croogo\Config;

use Cake\Core\App;
use Cake\Core\Configure;
use Cake\Core\Plugin;
use Cake\Log\Log;
use Cake\Utility\Hash;
use Cake\Utility\Inflector;

use Croogo\Croogo\Croogo;
use Croogo\Croogo\Cache\CroogoCache;
use Croogo\Croogo\Configure\CroogoJsonReader;
use Croogo\Croogo\CroogoStatus;
use Croogo\Croogo\Event\CroogoEventManager;
use Croogo\Extensions\CroogoPlugin;

/**
 * Default Acl plugin.  Custom Acl plugin should override this value.
 */
Configure::write('Site.acl_plugin', 'Acl');

/**
 * Default API Route Prefix. This can be overriden in settings.
 */
Configure::write('Croogo.Api.path', 'api');

/**
 * Admin theme
 */
//Configure::write('Site.admin_theme', 'sample');

/**
 * Cache configuration
 */
$defaultEngine = Configure::read('Cache.defaultEngine');
$defaultPrefix = Configure::read('Cache.defaultPrefix');
$cacheConfig = array(
	'duration' => '+1 hour',
	'path' => CACHE . 'queries' . DS,
	'className' => $defaultEngine,
	'prefix' => $defaultPrefix,
);
Configure::write('Cache.defaultConfig', $cacheConfig);

/**
 * Settings
 */
Configure::config('settings', new CroogoJsonReader());
if (file_exists(APP . 'Config' . DS . 'settings.json')) {
	Configure::load('settings', 'settings');
}

/**
 * Locale
 */
Configure::write('Config.language', Configure::read('Site.locale'));

/**
 * Assets
 */
if (Configure::check('Site.asset_timestamp')) {
	$timestamp = Configure::read('Site.asset_timestamp');
	Configure::write(
		'Asset.timestamp',
		is_numeric($timestamp) ? (bool) $timestamp : $timestamp
	);
	unset($timestamp);
}

/**
 * Extensions
 */
Plugin::load(['Extensions' => [
	'autoload' => true,
	'bootstrap' => true,
	'routes' => true,
	'namespace' => 'Croogo\\Extensions\\',
	'classBase' => false,
]]);
Configure::load('Extensions.events');

/**
 * Setup custom paths
 */
$croogoPath = Plugin::path('Croogo');
App::build(array(
	'Console/Command' => array($croogoPath . 'Console' . DS . 'Command' . DS),
	'View' => array($croogoPath . 'View' . DS),
	'View/Helper' => array($croogoPath . 'View' . DS . 'Helper' . DS),
), App::APPEND);
if ($theme = Configure::read('Site.theme')) {
	App::build(array(
		'View/Helper' => array(App::themePath($theme) . 'Helper' . DS),
	));
}

/**
 * List of core plugins
 */
$corePlugins = [
	'Settings', 'Acl', 'Blocks', 'Comments', 'Contacts', 'Menus', 'Meta',
	'Nodes', 'Taxonomy', 'Users', 'Wysiwyg', 'Ckeditor',
];
Configure::write('Core.corePlugins', $corePlugins);

/**
 * Plugins
 */
$aclPlugin = Configure::read('Site.acl_plugin');
$pluginBootstraps = Configure::read('Hook.bootstraps');
$plugins = array_filter(explode(',', $pluginBootstraps));

if (!in_array($aclPlugin, $plugins)) {
	$plugins = Hash::merge((array)$aclPlugin, $plugins);
}
foreach ($plugins as $plugin) {
	$pluginName = Inflector::camelize($plugin);
	$pluginPath = APP . 'Plugin' . DS . $pluginName;
	if (!file_exists($pluginPath)) {
		$pluginFound = false;
		foreach (App::path('Plugin') as $path) {
			if (is_dir($path . $pluginName)) {
				$pluginFound = true;
				break;
			}
		}
		if (!$pluginFound) {
			Log::error('Plugin not found during bootstrap: ' . $pluginName);
			continue;
		}
	}
	$option = array(
		$pluginName => array(
			'autoload' => true,
			'bootstrap' => true,
			'ignoreMissing' => true,
			'routes' => true,
		)
	);
	if (in_array($pluginName, $corePlugins)) {
		$option[$pluginName]['namespace'] = 'Croogo\\' . $pluginName . '\\';
		$option[$pluginName]['classBase'] = false;
	}
	CroogoPlugin::load($option);
}
CroogoEventManager::loadListeners();
Croogo::dispatchEvent('Croogo.bootstrapComplete');
{'fraction_non_alphanumeric': 0.2031599344164555, 'fraction_numerical': 0.00044716053063049635, 'mean_word_length': 5.050495942290351, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 36, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1988570', 'n_tokens_mistral': 2400, 'n_tokens_neox': 2302, 'n_words': 440}