Beispiel #1
0
 /**
  * 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;
 }