本文整理汇总了PHP中CRM_Utils_System::loadBootstrap方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Utils_System::loadBootstrap方法的具体用法?PHP CRM_Utils_System::loadBootstrap怎么用?PHP CRM_Utils_System::loadBootstrap使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CRM_Utils_System
的用法示例。
在下文中一共展示了CRM_Utils_System::loadBootstrap方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: bootstrap
private function bootstrap($cmsRoot, $civicrm_config_path)
{
define('CIVICRM_CMSDIR', $cmsRoot);
require_once $civicrm_config_path;
// so the configuration works with php-cli
$_SERVER['PHP_SELF'] = "/index.php";
$_SERVER['HTTP_HOST'] = 'localhost';
// $this->_site;
$_SERVER['REMOTE_ADDR'] = "127.0.0.1";
$_SERVER['SERVER_SOFTWARE'] = NULL;
$_SERVER['REQUEST_METHOD'] = 'GET';
// SCRIPT_FILENAME needed by CRM_Utils_System::cmsRootPath
$_SERVER['SCRIPT_FILENAME'] = __FILE__;
// CRM-8917 - check if script name starts with /, if not - prepend it.
if (ord($_SERVER['SCRIPT_NAME']) != 47) {
$_SERVER['SCRIPT_NAME'] = '/' . $_SERVER['SCRIPT_NAME'];
}
$config = \CRM_Core_Config::singleton();
// HTTP_HOST will be 'localhost' unless overwritten with the -s argument.
// Now we have a Config object, we can set it from the Base URL.
if ($_SERVER['HTTP_HOST'] == 'localhost') {
$_SERVER['HTTP_HOST'] = preg_replace('!^https?://([^/]+)/.*$!i', '$1', $config->userFrameworkBaseURL);
}
global $civicrm_root;
if (!\CRM_Utils_System::loadBootstrap(array(), FALSE, FALSE, $civicrm_root)) {
throw new \Exception("Failed to bootstrap CMS");
// return FALSE;
}
return TRUE;
}
示例2: _bootstrap
/**
* @return bool
*/
private function _bootstrap()
{
// so the configuration works with php-cli
$_SERVER['PHP_SELF'] = "/index.php";
$_SERVER['HTTP_HOST'] = $this->_site;
$_SERVER['REMOTE_ADDR'] = "127.0.0.1";
$_SERVER['SERVER_SOFTWARE'] = NULL;
$_SERVER['REQUEST_METHOD'] = 'GET';
// SCRIPT_FILENAME needed by CRM_Utils_System::cmsRootPath
$_SERVER['SCRIPT_FILENAME'] = __FILE__;
// CRM-8917 - check if script name starts with /, if not - prepend it.
if (ord($_SERVER['SCRIPT_NAME']) != 47) {
$_SERVER['SCRIPT_NAME'] = '/' . $_SERVER['SCRIPT_NAME'];
}
$civicrm_root = dirname(__DIR__);
chdir($civicrm_root);
require_once 'civicrm.config.php';
// autoload
if (!class_exists('CRM_Core_ClassLoader')) {
require_once $civicrm_root . '/CRM/Core/ClassLoader.php';
}
CRM_Core_ClassLoader::singleton()->register();
$this->_config = CRM_Core_Config::singleton();
// HTTP_HOST will be 'localhost' unless overwritten with the -s argument.
// Now we have a Config object, we can set it from the Base URL.
if ($_SERVER['HTTP_HOST'] == 'localhost') {
$_SERVER['HTTP_HOST'] = preg_replace('!^https?://([^/]+)/$!i', '$1', $this->_config->userFrameworkBaseURL);
}
$class = 'CRM_Utils_System_' . $this->_config->userFramework;
$cms = new $class();
if (!CRM_Utils_System::loadBootstrap(array(), FALSE, FALSE, $civicrm_root)) {
$this->_log(ts("Failed to bootstrap CMS"));
return FALSE;
}
if (strtolower($this->_entity) == 'job') {
if (!$this->_user) {
$this->_log(ts("Jobs called from cli.php require valid user as parameter"));
return FALSE;
}
}
if (!empty($this->_user)) {
if (!CRM_Utils_System::authenticateScript(TRUE, $this->_user, $this->_password, TRUE, FALSE, FALSE)) {
$this->_log(ts("Failed to login as %1. Wrong username or password.", array('1' => $this->_user)));
return FALSE;
}
if (!$cms->loadUser($this->_user)) {
$this->_log(ts("Failed to login as %1", array('1' => $this->_user)));
return FALSE;
}
}
return TRUE;
}
示例3: _bootstrap
private function _bootstrap()
{
// so the configuration works with php-cli
$_SERVER['PHP_SELF'] = "/index.php";
$_SERVER['HTTP_HOST'] = $this->_site;
$_SERVER['REMOTE_ADDR'] = "127.0.0.1";
// SCRIPT_FILENAME needed by CRM_Utils_System::cmsRootPath
$_SERVER['SCRIPT_FILENAME'] = __FILE__;
// CRM-8917 - check if script name starts with /, if not - prepend it.
if (ord($_SERVER['SCRIPT_NAME']) != 47) {
$_SERVER['SCRIPT_NAME'] = '/' . $_SERVER['SCRIPT_NAME'];
}
$civicrm_root = dirname(__DIR__);
chdir($civicrm_root);
require_once 'civicrm.config.php';
// autoload
require_once $civicrm_root . '/CRM/Core/ClassLoader.php';
CRM_Core_ClassLoader::singleton()->register();
require_once 'CRM/Core/Config.php';
$this->_config = CRM_Core_Config::singleton();
require_once 'CRM/Utils/System.php';
$class = 'CRM_Utils_System_' . $this->_config->userFramework;
$cms = new $class();
if (!CRM_Utils_System::loadBootstrap(array(), FALSE, FALSE, $civicrm_root)) {
$this->_log(ts("Failed to bootstrap CMS"));
return FALSE;
}
if (strtolower($this->_entity) == 'job') {
if (!$this->_user) {
$this->_log(ts("Jobs called from cli.php require valid user as parameter"));
return FALSE;
}
}
if (!empty($this->_user)) {
if (!$cms->loadUser($this->_user)) {
$this->_log(ts("Failed to login as %1", array('1' => $this->_user)));
return FALSE;
}
}
return TRUE;
}