Skip to content

Commit

Permalink
Revert "Dev: Add config file for plugin"
Browse files Browse the repository at this point in the history
This reverts commit c52d2f0.
  • Loading branch information
olleharstedt committed May 5, 2016
1 parent faba5ef commit a21f380
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 54 deletions.
1 change: 0 additions & 1 deletion application/controllers/admin/pluginmanager.php
Expand Up @@ -43,7 +43,6 @@ public function index()
if (array_key_exists($oPlugin->name, $aDiscoveredPlugins))
{
$aPluginSettings = App()->getPluginManager()->loadPlugin($oPlugin->name, $oPlugin->id)->getPluginSettings(false);
$pluginConfig = $oPlugin->getConfig();
$data[] = array(
'id' => $oPlugin->id,
'name' => $aDiscoveredPlugins[$oPlugin->name]['pluginName'],
Expand Down
54 changes: 1 addition & 53 deletions application/models/Plugin.php
Expand Up @@ -29,56 +29,4 @@ public static function model($className = __CLASS__) {
public function tableName() {
return '{{plugins}}';
}

public function getConfig() {
$file = Yii::app()->basePath
. DIRECTORY_SEPARATOR . '..'
. DIRECTORY_SEPARATOR . 'plugins'
. DIRECTORY_SEPARATOR . $this->name
. DIRECTORY_SEPARATOR . 'config.php';

// No config file, just return empty array
if (!file_exists($file)) {
return array();
}

$config = include($file);

if (!isset($config['version'])) {
throw new Exception("Config file need a version number");
}

// Compare with 0.0.1-dev, which is the lowest possible version.
$isPhpVersion = version_compare($config['version'], '0.0.1-dev');

if ($isPhpVersion === -1) {
throw new Exception("Version in config is not a PHP version: " . $config['version']);
}

$status = $this->getStatus($config['version']);

return $config;
}

/**
* Return version status, e.g. "alpha" if
* version is "1.2.3-alpha"
*
* @param string $version
* @return string
*/
protected function getStatus($version) {
$versionAndStatus = explode('-', $version);
var_dump($versionAndStatus);

if (count($versionAndStatus) === 1) {
return "";
}
elseif (count($versionAndStatus) === 2) {
return $versionAndStatus[1];
}
else {
throw new Exception("Invalid version: more than one slash ('-'): " . $version);
}
}
}
}

0 comments on commit a21f380

Please sign in to comment.