本文整理汇总了PHP中CRM_Utils_System::isInUpgradeMode方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Utils_System::isInUpgradeMode方法的具体用法?PHP CRM_Utils_System::isInUpgradeMode怎么用?PHP CRM_Utils_System::isInUpgradeMode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CRM_Utils_System
的用法示例。
在下文中一共展示了CRM_Utils_System::isInUpgradeMode方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: register
/**
* Registers this instance as an autoloader.
* @return CRM_Extension_ClassLoader
*/
public function register()
{
// In pre-installation environments, don't bother with caching.
if (!defined('CIVICRM_TEMPLATE_COMPILEDIR') || !defined('CIVICRM_DSN') || defined('CIVICRM_TEST') || \CRM_Utils_System::isInUpgradeMode()) {
return $this->buildClassLoader()->register();
}
$file = $this->getCacheFile();
if (file_exists($file)) {
$loader = (require $file);
} else {
$loader = $this->buildClassLoader();
$ser = serialize($loader);
file_put_contents($file, sprintf("<?php\nreturn unserialize(%s);", var_export($ser, 1)));
}
return $loader->register();
}
示例2: loadContainer
/**
* Find a cached container definition or construct a new one.
*
* There are many weird contexts in which Civi initializes (eg different
* variations of multitenancy and different permutations of CMS/CRM bootstrap),
* and hook_container may fire a bit differently in each context. To mitigate
* risk of leaks between environments, we compute a unique envID
* (md5(DB_NAME, HTTP_HOST, SCRIPT_FILENAME, etc)) and use separate caches for
* each (eg "templates_c/CachedCiviContainer.$ENVID.php").
*
* Constants:
* - CIVICRM_CONTAINER_CACHE -- 'always' [default], 'never', 'auto'
* - CIVICRM_DSN
* - CIVICRM_DOMAIN_ID
* - CIVICRM_TEMPLATE_COMPILEDIR
*
* @return ContainerInterface
*/
public function loadContainer()
{
// Note: The container's raison d'etre is to manage construction of other
// services. Consequently, we assume a minimal service available -- the classloader
// has been setup, and civicrm.settings.php is loaded, but nothing else works.
$cacheMode = defined('CIVICRM_CONTAINER_CACHE') ? CIVICRM_CONTAINER_CACHE : 'always';
// In pre-installation environments, don't bother with caching.
if (!defined('CIVICRM_TEMPLATE_COMPILEDIR') || !defined('CIVICRM_DSN') || $cacheMode === 'never' || \CRM_Utils_System::isInUpgradeMode()) {
return $this->createContainer();
}
$envId = \CRM_Core_Config_Runtime::getId();
$file = CIVICRM_TEMPLATE_COMPILEDIR . "/CachedCiviContainer.{$envId}.php";
$containerConfigCache = new ConfigCache($file, $cacheMode === 'auto');
if (!$containerConfigCache->isFresh()) {
$containerBuilder = $this->createContainer();
$containerBuilder->compile();
$dumper = new PhpDumper($containerBuilder);
$containerConfigCache->write($dumper->dump(array('class' => 'CachedCiviContainer')), $containerBuilder->getResources());
}
require_once $file;
$c = new \CachedCiviContainer();
$c->set('service_container', $c);
return $c;
}