+--------------------------------------------------------------------+
| CiviCRM version 4.7 |
+--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2017 |
+ | Copyright CiviCRM LLC (c) 2004-2018 |
+--------------------------------------------------------------------+
| This file is a part of CiviCRM. |
| |
* module-extensions.
*
* @package CRM
- * @copyright CiviCRM LLC (c) 2004-2017
+ * @copyright CiviCRM LLC (c) 2004-2018
*/
class CRM_Extension_Mapper {
return $urls;
}
+ /**
+ * Get a list of extension keys, filtered by the corresponding file path.
+ *
+ * @param string $pattern
+ * A file path. To search subdirectories, append "*".
+ * Ex: "/var/www/extensions/*"
+ * Ex: "/var/www/extensions/org.foo.bar"
+ * @return array
+ * Array(string $key).
+ * Ex: array("org.foo.bar").
+ */
+ public function getKeysByPath($pattern) {
+ $keys = array();
+
+ if (CRM_Utils_String::endsWith($pattern, '*')) {
+ $prefix = rtrim($pattern, '*');
+ foreach ($this->container->getKeys() as $key) {
+ $path = CRM_Utils_File::addTrailingSlash($this->container->getPath($key));
+ if (realpath($prefix) == realpath($path) || CRM_Utils_File::isChildPath($prefix, $path)) {
+ $keys[] = $key;
+ }
+ }
+ }
+ else {
+ foreach ($this->container->getKeys() as $key) {
+ $path = CRM_Utils_File::addTrailingSlash($this->container->getPath($key));
+ if (realpath($pattern) == realpath($path)) {
+ $keys[] = $key;
+ }
+ }
+ }
+
+ return $keys;
+ }
+
+ /**
+ * @return array
+ * Ex: $result['org.civicrm.foobar'] = new CRM_Extension_Info(...).
+ * @throws \CRM_Extension_Exception
+ * @throws \Exception
+ */
+ public function getAllInfos() {
+ foreach ($this->container->getKeys() as $key) {
+ $this->keyToInfo($key);
+ }
+ return $this->infos;
+ }
+
/**
* @param string $name
*