+--------------------------------------------------------------------+
| CiviCRM version 4.7 |
+--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2017 |
+ | Copyright CiviCRM LLC (c) 2004-2018 |
+--------------------------------------------------------------------+
| This file is a part of CiviCRM. |
| |
* Metadata for an extension (e.g. the extension's "info.xml" file)
*
* @package CRM
- * @copyright CiviCRM LLC (c) 2004-2017
+ * @copyright CiviCRM LLC (c) 2004-2018
*/
class CRM_Extension_Info {
*/
public $classloader = array();
+ /**
+ * @var array
+ * Each item is they key-name of an extension required by this extension.
+ */
+ public $requires = array();
+
/**
* Load extension info an XML file.
*
return $instance;
}
+ /**
+ * Build a reverse-dependency map.
+ *
+ * @param array $infos
+ * The universe of available extensions.
+ * Ex: $infos['org.civicrm.foobar'] = new CRM_Extension_Info().
+ * @return array
+ * If "org.civicrm.api" is required by "org.civicrm.foo", then return
+ * array('org.civicrm.api' => array(CRM_Extension_Info[org.civicrm.foo])).
+ * Array(string $key => array $requiredBys).
+ */
+ public static function buildReverseMap($infos) {
+ $revMap = array();
+ foreach ($infos as $info) {
+ foreach ($info->requires as $key) {
+ $revMap[$key][] = $info;
+ }
+ }
+ return $revMap;
+ }
+
/**
* @param null $key
* @param null $type
);
}
}
+ elseif ($attr === 'requires') {
+ $this->requires = array();
+ foreach ($val->ext as $ext) {
+ $this->requires[] = (string) $ext;
+ }
+ }
else {
$this->$attr = CRM_Utils_XML::xmlObjToArray($val);
}