Example #1
0
 /**
  * Find the $info and $typeManager for a $key
  *
  * @param $key
  *
  * @throws CRM_Extension_Exception
  * @return array
  *   (0 => CRM_Extension_Info, 1 => CRM_Extension_Manager_Interface)
  */
 private function _getInfoTypeHandler($key)
 {
     $info = $this->mapper->keyToInfo($key);
     // throws Exception
     if (array_key_exists($info->type, $this->typeManagers)) {
         return array($info, $this->typeManagers[$info->type]);
     } else {
         throw new CRM_Extension_Exception("Unrecognized extension type: " . $info->type);
     }
 }
Example #2
0
 /**
  * @return \Composer\Autoload\ClassLoader
  * @throws \CRM_Extension_Exception
  * @throws \Exception
  */
 public function buildClassLoader()
 {
     $loader = new \Composer\Autoload\ClassLoader();
     $statuses = $this->manager->getStatuses();
     foreach ($statuses as $key => $status) {
         if ($status !== CRM_Extension_Manager::STATUS_INSTALLED) {
             continue;
         }
         $path = $this->mapper->keyToBasePath($key);
         $info = $this->mapper->keyToInfo($key);
         if (!empty($info->classloader)) {
             foreach ($info->classloader as $mapping) {
                 switch ($mapping['type']) {
                     case 'psr4':
                         $loader->setPsr4($mapping['prefix'], $path . '/' . $mapping['path']);
                         break;
                 }
                 $result[] = $mapping;
             }
         }
     }
     return $loader;
 }