Skip to content
Snippets Groups Projects
Commit 0aa7f7b7 authored by Akshath's avatar Akshath
Browse files

Fix for #1535 - Provide hooks to plugin custom connectors and avoid modification in core files

parent a9381bc0
No related branches found
No related tags found
No related merge requests found
......@@ -10,3 +10,11 @@
//Maximum number of Mailboxes in mail converter
$max_mailboxes = 3;
/**
* Configure runtime connectors to customization in core files.
* Ex: Sessions are currently handled by PHP default session handler.
* This can be customized using runtime connector hook and avoid core file modifications.
* array('session' => 'Vtiger_CustomSession_Handler')
*/
$runtime_connectors = array();
\ No newline at end of file
......@@ -40,6 +40,7 @@ require_once 'vtlib/Vtiger/Deprecated.php';
require_once 'includes/runtime/Cache.php';
require_once 'modules/Vtiger/helpers/Util.php';
require_once 'vtlib/Vtiger/AccessControl.php';
require_once 'includes/runtime/Configs.php';
// Constants to be defined here
// For Migration status.
......
......@@ -8,6 +8,16 @@
* All Rights Reserved.
************************************************************************************/
/**
* Override default user-session storage functions if custom session connector exist.
*/
$runtime_configs = Vtiger_Runtime_Configs::getInstance();
$custom_session_handlerclass = $runtime_configs->getConnector('session');
if($custom_session_handlerclass) {
$handler = $custom_session_handlerclass::getInstance();
session_set_save_handler($handler, true);
}
// Import dependencies
include_once 'libraries/HTTP_Session2/HTTP/Session2.php';
......
......@@ -17,7 +17,9 @@ class Vtiger_Cache {
protected $connector;
private function __construct() {
$this->connector = Vtiger_Cache_Connector::getInstance();
$runtime_configs = Vtiger_Runtime_Configs::getInstance();
$connector_class = $runtime_configs->getConnector('cache', 'Vtiger_Cache_Connector');
$this->connector = $connector_class::getInstance();
}
public static function getInstance(){
......
<?php
/*+***********************************************************************************
* The contents of this file are subject to the vtiger CRM Public License Version 1.0
* ("License"); You may not use this file except in compliance with the License
* The Original Code is: vtiger CRM Open Source
* The Initial Developer of the Original Code is vtiger.
* Portions created by vtiger are Copyright (C) vtiger.
* All Rights Reserved.
*************************************************************************************/
require_once 'includes/runtime/BaseModel.php';
class Vtiger_Runtime_Configs extends Vtiger_Base_Model {
private static $instance = false;
public static function getInstance() {
if(self::$instance === false) {
self::$instance = new self();
}
return self::$instance;
}
/**
* Function to fetch runtime connectors configured in config_override.php
* @params $identifier - Connector identifier Ex: session
* @params $default - Default connector class name.
*/
public function getConnector($identifier, $default = '') {
global $runtime_connectors;
$connector = '';
if(isset($runtime_connectors[$identifier])) {
$connector = $runtime_connectors[$identifier];
}
if(empty($connector) && !empty($default)) {
$connector = $default;
}
return $connector;
}
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment