Commit fc9ea759 authored by Yassine Doghri's avatar Yassine Doghri
Browse files

feat(plugins): add `minCastopodVersion` to denote incompatibility with previous Castopod versions

parent fee79059
Loading
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -62,6 +62,10 @@ directories should refuse to publish the plugin.

Array of strings to help your plugin get discovered when listed in repositories.

### minCastopodVersion

The minimal version of Castopod with which the plugin is compatible.

### hooks

List of hooks used by the plugin. If the hook is not specified, Castopod will
+15 −1
Original line number Diff line number Diff line
@@ -54,7 +54,16 @@ abstract class BasePlugin implements PluginInterface
        $this->manifest = new Manifest($this->key);
        $this->manifest->loadFromFile($manifestPath);

        // check compatibility with Castopod version
        if ($this->manifest->minCastopodVersion !== null && version_compare(
            CP_VERSION,
            $this->manifest->minCastopodVersion,
            '<'
        )) {
            $this->status = PluginStatus::INCOMPATIBLE;
        } else {
            $this->status = get_plugin_setting($this->key, 'active') ? PluginStatus::ACTIVE : PluginStatus::INACTIVE;
        }

        $this->iconSrc = $this->loadIcon($directory . '/icon.svg');

@@ -214,6 +223,11 @@ abstract class BasePlugin implements PluginInterface
        return $settings->{$type};
    }

    final public function getMinCastopodVersion(): string
    {
        return $this->manifest->minCastopodVersion ?? '';
    }

    /**
     * @return list<string>
     */
+1 −0
Original line number Diff line number Diff line
@@ -7,6 +7,7 @@ namespace Modules\Plugins\Core;
enum PluginStatus: string
{
    case INVALID = 'invalid';
    case INCOMPATIBLE = 'incompatible';
    case INACTIVE = 'inactive';
    case ACTIVE = 'active';
}
+0 −2
Original line number Diff line number Diff line
@@ -19,8 +19,6 @@ use Modules\Plugins\Config\Plugins as PluginsConfig;
 */
class Plugins
{
    public const API_VERSION = '1.0';

    /**
     * @var list<string>
     */
+2 −0
Original line number Diff line number Diff line
@@ -29,6 +29,8 @@ return [
    'active' => 'Active',
    'inactive' => 'Inactive',
    'invalid' => 'Invalid',
    'incompatible' => 'Incompatible',
    'incompatible_hint' => 'Plugin requires Castopod v{minCastopodVersion} minimum.',
    'uninstall' => 'Uninstall',
    'keywords' => [
        'podcasting20' => 'Podcasting 2.0',
Loading