本文整理匯總了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');
}