checkExtension() can also check with the configuration array

This commit is contained in:
Uwe Steinmann 2018-03-14 11:20:55 +01:00
parent f386e83f2e
commit 0a3d3ea382

View File

@ -174,15 +174,17 @@ class SeedDMS_Extension_Mgr {
} /* }}} */
/**
* Check content of extension directory
* Check content of extension directory or configuration of extension
*
* @param string $dir full path to extension directory or extension name
* @param string|array $dir full path to extension directory or extension name
* or an array containing the configuration.
* @param boolean $noconstraints set to true if constraints to local seeddms
* installation shall not be checked.
*/
public function checkExtension($dir, $noconstraints=false) { /* {{{ */
public function checkExtension($dir, $options=array()) { /* {{{ */
$this->errmsgs = array();
if(is_string($dir)) {
if(!file_exists($dir)) {
if(!file_exists($this->extdir.'/'.$dir))
return false;
@ -204,6 +206,14 @@ class SeedDMS_Extension_Mgr {
}
$extconf = $EXT_CONF[$extname];
} elseif(is_array($dir)) {
$extconf = $dir;
/* If just the configuration is passed, then there is no way to check
* for existence of files.
*/
$options['nofiles'] = true;
}
if(!isset($extconf['constraints']['depends']['seeddms'])) {
$this->errmsgs[] = "Missing dependency on SeedDMS";
}
@ -219,14 +229,17 @@ class SeedDMS_Extension_Mgr {
if(!isset($extconf['author'])) {
$this->errmsgs[] = "Missing author";
}
if(!isset($options['nofiles']) || $options['nofiles'] == false) {
if(!empty($extconf['language']['file']) && !file_exists($dir."/".$extconf['language']['file'])) {
$this->errmsgs[] = "Missing language file";
}
if(!empty($extconf['class']['file']) && !file_exists($dir."/".$extconf['class']['file'])) {
$this->errmsgs[] = "Missing class file";
}
}
if(!$noconstraints && isset($extconf['constraints']['depends'])) {
if(!isset($options['noconstraints']) || $options['noconstraints'] == false) {
if(isset($extconf['constraints']['depends'])) {
foreach($extconf['constraints']['depends'] as $dkey=>$dval) {
switch($dkey) {
case 'seeddms':
@ -252,6 +265,7 @@ class SeedDMS_Extension_Mgr {
}
}
}
}
if($this->errmsgs)
return false;