本文整理汇总了PHP中CRM_Core_Resources::getPath方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Core_Resources::getPath方法的具体用法?PHP CRM_Core_Resources::getPath怎么用?PHP CRM_Core_Resources::getPath使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CRM_Core_Resources
的用法示例。
在下文中一共展示了CRM_Core_Resources::getPath方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getResources
/**
* Get resources for one or more modules.
*
* @param string|array $moduleNames
* List of module names.
* @param string $resType
* Type of resource ('js', 'css', 'settings').
* @param string $refType
* Type of reference to the resource ('cacheUrl', 'rawUrl', 'path', 'settings').
* @return array
* List of URLs or paths.
* @throws \CRM_Core_Exception
*/
public function getResources($moduleNames, $resType, $refType)
{
$result = array();
$moduleNames = (array) $moduleNames;
foreach ($moduleNames as $moduleName) {
$module = $this->getModule($moduleName);
if (isset($module[$resType])) {
foreach ($module[$resType] as $file) {
switch ($refType) {
case 'path':
$result[] = $this->res->getPath($module['ext'], $file);
break;
case 'rawUrl':
$result[] = $this->res->getUrl($module['ext'], $file);
break;
case 'cacheUrl':
$result[] = $this->res->getUrl($module['ext'], $file, TRUE);
break;
case 'settings':
if (!empty($module[$resType])) {
$result[$moduleName] = $module[$resType];
}
break;
default:
throw new \CRM_Core_Exception("Unrecognized resource format");
}
}
}
}
return $result;
}
示例2: testGetModules
/**
* Modules appear to be well-defined.
*/
public function testGetModules()
{
$modules = $this->angular->getModules();
$counts = array('js' => 0, 'css' => 0, 'partials' => 0, 'settings' => 0);
foreach ($modules as $module) {
$this->assertTrue(is_array($module));
$this->assertTrue(is_string($module['ext']));
if (isset($module['js'])) {
$this->assertTrue(is_array($module['js']));
foreach ($module['js'] as $file) {
$this->assertTrue(file_exists($this->res->getPath($module['ext'], $file)));
$counts['js']++;
}
}
if (isset($module['css'])) {
$this->assertTrue(is_array($module['css']));
foreach ($module['css'] as $file) {
$this->assertTrue(file_exists($this->res->getPath($module['ext'], $file)));
$counts['css']++;
}
}
if (isset($module['partials'])) {
$this->assertTrue(is_array($module['partials']));
foreach ((array) $module['partials'] as $basedir) {
$this->assertTrue(is_dir($this->res->getPath($module['ext']) . '/' . $basedir));
$counts['partials']++;
}
}
if (isset($module['settings'])) {
$this->assertTrue(is_array($module['settings']));
foreach ($module['settings'] as $name => $value) {
$counts['settings']++;
}
}
}
$this->assertTrue($counts['js'] > 0, 'Expect to find at least one JS file');
$this->assertTrue($counts['css'] > 0, 'Expect to find at least one CSS file');
$this->assertTrue($counts['partials'] > 0, 'Expect to find at least one partial HTML file');
$this->assertTrue($counts['settings'] > 1, 'Expect to find at least one setting');
}