本文整理汇总了PHP中Civi::paths方法的典型用法代码示例。如果您正苦于以下问题:PHP Civi::paths方法的具体用法?PHP Civi::paths怎么用?PHP Civi::paths使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Civi
的用法示例。
在下文中一共展示了Civi::paths方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: readActiveConfig
/**
* @return array
*/
public function readActiveConfig()
{
if (!defined('CIVICRM_SETTINGS_PATH') || CIVICRM_SETTINGS_PATH !== $this->settingsFile) {
return array();
}
$paths = is_callable(array('Civi', 'paths')) ? \Civi::paths() : NULL;
$data = array('CMS_DB_DSN' => CIVICRM_UF_DSN, 'CMS_VERSION' => \CRM_Core_Config::singleton()->userSystem->getVersion(), 'CIVI_DB_DSN' => CIVICRM_DSN, 'CIVI_SITE_KEY' => CIVICRM_SITE_KEY, 'CIVI_VERSION' => \CRM_Utils_System::version(), 'CIVI_SETTINGS' => CIVICRM_SETTINGS_PATH, 'CIVI_TEMPLATEC' => \CRM_Core_Config::singleton()->templateCompileDir, 'CIVI_UF' => \CRM_Core_Config::singleton()->userFramework, 'IS_INSTALLED' => '1', 'SITE_TYPE' => 'cv-auto', 'CMS_URL' => $paths ? \Civi::paths()->getUrl('[cms.root]/', 'absolute') : \CRM_Utils_System::languageNegotiationURL(\CRM_Utils_System::baseCMSURL(), FALSE, TRUE), 'CMS_ROOT' => $paths ? \Civi::paths()->getPath('[cms.root]/.') : \CRM_Core_Config::singleton()->userSystem->cmsRootPath(), 'CIVI_CORE' => $paths ? \Civi::paths()->getPath('[civicrm.root]/.') : $GLOBALS['civicrm_root'], 'CIVI_URL' => $paths ? \Civi::paths()->getUrl('[civicrm.root]/', 'absolute') : '', 'CIVI_FILES' => $paths ? \Civi::paths()->getPath('[civicrm.root]/.') : dirname(\CRM_Core_Config::singleton()->templateCompileDir));
return $data;
}
示例2: getExampleFile
/**
* AJAX callback to fetch examples.
*/
public static function getExampleFile()
{
if (!empty($_GET['entity']) && strpos($_GET['entity'], '.') === FALSE) {
$examples = array();
foreach (scandir(\Civi::paths()->getPath("[civicrm.root]/api/v3/examples/{$_GET['entity']}")) as $item) {
$item = str_replace('.php', '', $item);
if ($item && strpos($item, '.') === FALSE) {
$examples[] = array('key' => $item, 'value' => $item);
}
}
CRM_Utils_JSON::output($examples);
}
if (!empty($_GET['file']) && strpos($_GET['file'], '.') === FALSE) {
$fileName = \Civi::paths()->getPath("[civicrm.root]/api/v3/examples/{$_GET['file']}.php");
if (file_exists($fileName)) {
echo file_get_contents($fileName);
} else {
echo "Not found.";
}
CRM_Utils_System::civiExit();
}
CRM_Utils_System::permissionDenied();
}
示例3: __get
public function __get($k)
{
if (!isset($this->map[$k])) {
throw new \CRM_Core_Exception("Cannot read unrecognized property CRM_Core_Config::\${$k}.");
}
if (isset($this->cache[$k])) {
return $this->cache[$k];
}
$type = $this->map[$k][0];
$name = isset($this->map[$k][1]) ? $this->map[$k][1] : $k;
switch ($type) {
case 'setting':
return $this->getSettings()->get($name);
case 'setting-path':
// Array(0 => $type, 1 => $setting, 2 => $actions).
$value = $this->getSettings()->get($name);
$value = Civi::paths()->getPath($value);
if ($value) {
$value = CRM_Utils_File::addTrailingSlash($value);
if (isset($this->map[$k][2]) && in_array('mkdir', $this->map[$k][2])) {
CRM_Utils_File::createDir($value);
}
if (isset($this->map[$k][2]) && in_array('restrict', $this->map[$k][2])) {
CRM_Utils_File::restrictAccess($value);
}
}
$this->cache[$k] = $value;
return $value;
case 'setting-url-abs':
$value = $this->getSettings()->get($name);
$this->cache[$k] = Civi::paths()->getUrl($value, 'absolute');
return $this->cache[$k];
case 'setting-url-rel':
$value = $this->getSettings()->get($name);
$this->cache[$k] = Civi::paths()->getUrl($value, 'relative');
return $this->cache[$k];
case 'runtime':
return \Civi\Core\Container::getBootService('runtime')->{$name};
case 'boot-svc':
$this->cache[$k] = \Civi\Core\Container::getBootService($name);
return $this->cache[$k];
case 'local':
$this->initLocals();
return $this->locals[$name];
case 'user-system':
$userSystem = \Civi\Core\Container::getBootService('userSystem');
$this->cache[$k] = call_user_func(array($userSystem, $name));
return $this->cache[$k];
case 'service':
return \Civi::service($name);
case 'callback':
// Array(0 => $type, 1 => $obj, 2 => $getter, 3 => $setter, 4 => $unsetter).
if (!isset($this->map[$k][1], $this->map[$k][2])) {
throw new \CRM_Core_Exception("Cannot find getter for property CRM_Core_Config::\${$k}");
}
return \Civi\Core\Resolver::singleton()->call(array($this->map[$k][1], $this->map[$k][2]), array($k));
default:
throw new \CRM_Core_Exception("Cannot read property CRM_Core_Config::\${$k} ({$type})");
}
}
示例4: settingPath
/**
* Determine whether the value contains a valid reference to a directory.
*
* Paths stored in the setting system may be absolute -- or may be
* relative to the default data directory.
*
* @param string $path
* @return bool
*/
public static function settingPath($path)
{
return is_dir(Civi::paths()->getPath($path));
}
示例5: __construct
/**
* Class constructor.
*/
public function __construct()
{
$this->localVersion = CRM_Utils_System::version();
$this->localMajorVersion = $this->getMajorVersion($this->localVersion);
$this->cacheFile = Civi::paths()->getPath(self::CACHEFILE_NAME);
}
示例6: __construct
/**
* Construct a resource manager.
*
* @param CRM_Extension_Mapper $extMapper
* Map extension names to their base path or URLs.
* @param CRM_Utils_Cache_Interface $cache
* JS-localization cache.
* @param string|null $cacheCodeKey Random code to append to resource URLs; changing the code forces clients to reload resources
*/
public function __construct($extMapper, $cache, $cacheCodeKey = NULL)
{
$this->extMapper = $extMapper;
$this->strings = new CRM_Core_Resources_Strings($cache);
$this->cacheCodeKey = $cacheCodeKey;
if ($cacheCodeKey !== NULL) {
$this->cacheCode = Civi::settings()->get($cacheCodeKey);
}
if (!$this->cacheCode) {
$this->resetCacheCode();
}
$this->ajaxPopupsEnabled = (bool) Civi::settings()->get('ajaxPopupsEnabled');
$this->paths = Civi::paths();
}
示例7: includeCustomPath
/**
* Include custom PHP and template paths
*/
public function includeCustomPath()
{
$customProprtyName = array('customPHPPathDir', 'customTemplateDir');
foreach ($customProprtyName as $property) {
$value = $this->getSettings()->get($property);
if (!empty($value)) {
$customPath = Civi::paths()->getPath($value);
set_include_path($customPath . PATH_SEPARATOR . get_include_path());
}
}
}
示例8: getConfigFile
/**
* @param bool $checkIfFileExists
* If false, this fn will return fileName even if it doesn't exist
*
* @return null|string
*/
public static function getConfigFile($checkIfFileExists = TRUE)
{
$fileName = Civi::paths()->getPath(self::CONFIG_FILENAME);
return !$checkIfFileExists || is_file($fileName) ? $fileName : NULL;
}