$this->baseUrl = rtrim($baseUrl, '/');
}
+ /**
+ * {@inheritdoc}
+ */
+ public function checkRequirements() {
+ $errors = array();
+
+ if (empty($this->baseDir) || !is_dir($this->baseDir)) {
+ $errors[] = array(
+ 'title' => ts('Invalid Base Directory'),
+ 'message' => ts('An extension container has been defined with a blank directory.'),
+ );
+ }
+ if (empty($this->baseUrl)) {
+ dpm($this);
+ $errors[] = array(
+ 'title' => ts('Invalid Base URL'),
+ 'message' => ts('An extension container has been defined with a blank URL.'),
+ );
+ }
+
+ return $errors;
+ }
+
/**
* {@inheritdoc}
*/
*/
protected function getRelPath($key) {
$keypaths = $this->getRelPaths();
- if (! isset($keypaths[$key])) {
+ if (!isset($keypaths[$key])) {
throw new CRM_Extension_Exception_MissingException("Failed to find extension: $key");
}
return $keypaths[$key];
*/
protected function getRelUrl($key) {
$relUrls = $this->getRelUrls();
- if (! isset($relUrls[$key])) {
+ if (!isset($relUrls[$key])) {
throw new CRM_Extension_Exception_MissingException("Failed to find extension: $key");
}
return $relUrls[$key];
/**
* {@inheritdoc}
*/
+ public function checkRequirements() {
+ $errors = array();
+ foreach ($this->containers as $container) {
+ $errors = array_merge($errors, $container->checkRequirements());
+ }
+ return $errors;
+ }
+ /**
+ * {@inheritdoc}
+ */
public function getKeys() {
$k2c = $this->getKeysToContainer();
return array_keys($k2c);
*/
interface CRM_Extension_Container_Interface {
+ /**
+ * Determine if any unmet requirements prevent use of this container.
+ *
+ * @return array list of error messages; empty if OK
+ */
+ public function checkRequirements();
+
/**
* Get a list of extensions available in this container
*