Skip to content

Commit

Permalink
Bump to API version 4
Browse files Browse the repository at this point in the history
  • Loading branch information
PhrozenByte committed Feb 6, 2022
1 parent ee90600 commit ea4fa66
Show file tree
Hide file tree
Showing 3 changed files with 135 additions and 1 deletion.
9 changes: 8 additions & 1 deletion PicoDeprecated.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class PicoDeprecated extends AbstractPicoPlugin
*
* @var int
*/
public const API_VERSION = 3;
public const API_VERSION = 4;

/**
* API version 0, used by Pico 0.9 and earlier
Expand Down Expand Up @@ -76,6 +76,13 @@ class PicoDeprecated extends AbstractPicoPlugin
*/
public const API_VERSION_3 = 3;

/**
* API version 4, used by Pico 3.0
*
* @var int
*/
public const API_VERSION_4 = 4;

/**
* Loaded plugins, indexed by API version
*
Expand Down
91 changes: 91 additions & 0 deletions plugins/PluginApi3Plugin.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
<?php
/**
* This file is part of Pico. It's copyrighted by the contributors recorded
* in the version control history of the file, available from the following
* original location:
*
* <https://github.com/picocms/pico-deprecated/blob/master/plugins/PluginApi3Plugin.php>
*
* SPDX-License-Identifier: MIT
* License-Filename: LICENSE
*/

namespace picocms\PicoDeprecated\Plugin;

use picocms\PicoDeprecated\AbstractPluginApiPlugin;
use PicoDeprecated;

/**
* Maintains backward compatibility with plugins using API version 3, written
* for Pico 2.1
*
* @author Daniel Rudolf
* @link http://picocms.org
* @license http://opensource.org/licenses/MIT The MIT License
* @version 3.0
*/
class PluginApi3Plugin extends AbstractPluginApiPlugin
{
/**
* This plugin extends {@see ThemeApi3Plugin}
*
* @var string[]
*/
protected $dependsOn = [ ThemeApi3Plugin::class ];

/**
* Map of core events matching event signatures of older API versions
*
* @see AbstractPluginApiPlugin::handleEvent()
*
* @var array<string,string>
*/
protected $eventAliases = [
'onPluginsLoaded' => [ 'onPluginsLoaded' ],
'onPluginManuallyLoaded' => [ 'onPluginManuallyLoaded' ],
'onConfigLoaded' => [ 'onConfigLoaded' ],
'onThemeLoading' => [ 'onThemeLoading' ],
'onThemeLoaded' => [ 'onThemeLoaded' ],
'onRequestUrl' => [ 'onRequestUrl' ],
'onRequestFile' => [ 'onRequestFile' ],
'onContentLoading' => [ 'onContentLoading' ],
'on404ContentLoading' => [ 'on404ContentLoading' ],
'on404ContentLoaded' => [ 'on404ContentLoaded' ],
'onContentLoaded' => [ 'onContentLoaded' ],
'onMetaParsing' => [ 'onMetaParsing' ],
'onMetaParsed' => [ 'onMetaParsed' ],
'onContentParsing' => [ 'onContentParsing' ],
'onContentPrepared' => [ 'onContentPrepared' ],
'onContentParsed' => [ 'onContentParsed' ],
'onPagesLoading' => [ 'onPagesLoading' ],
'onSinglePageLoading' => [ 'onSinglePageLoading' ],
'onSinglePageContent' => [ 'onSinglePageContent' ],
'onSinglePageLoaded' => [ 'onSinglePageLoaded' ],
'onPagesDiscovered' => [ 'onPagesDiscovered' ],
'onPagesLoaded' => [ 'onPagesLoaded' ],
'onCurrentPageDiscovered' => [ 'onCurrentPageDiscovered' ],
'onPageTreeBuilt' => [ 'onPageTreeBuilt' ],
'onPageRendering' => [ 'onPageRendering' ],
'onPageRendered' => [ 'onPageRendered' ],
'onMetaHeaders' => [ 'onMetaHeaders' ],
'onYamlParserRegistered' => [ 'onYamlParserRegistered' ],
'onParsedownRegistered' => [ 'onParsedownRegistered' ],
'onTwigRegistered' => [ 'onTwigRegistered' ],
];

/**
* {@inheritDoc}
*/
public function getApiVersion()
{
return PicoDeprecated::API_VERSION_4;
}

/**
* {@inheritDoc}
*/
public function getApiVersionSupport()
{
return PicoDeprecated::API_VERSION_3;
}
}
36 changes: 36 additions & 0 deletions plugins/ThemeApi3Plugin.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?php
/**
* This file is part of Pico. It's copyrighted by the contributors recorded
* in the version control history of the file, available from the following
* original location:
*
* <https://github.com/picocms/pico-deprecated/blob/master/plugins/ThemeApi3Plugin.php>
*
* SPDX-License-Identifier: MIT
* License-Filename: LICENSE
*/

namespace picocms\PicoDeprecated\Plugin;

use picocms\PicoDeprecated\AbstractPlugin;
use PicoDeprecated;

/**
* Maintains backward compatibility with themes using API version 3, written
* for Pico 2.1
*
* @author Daniel Rudolf
* @link http://picocms.org
* @license http://opensource.org/licenses/MIT The MIT License
* @version 3.0
*/
class ThemeApi3Plugin extends AbstractPlugin
{
/**
* {@inheritDoc}
*/
public function getApiVersion()
{
return PicoDeprecated::API_VERSION_4;
}
}

0 comments on commit ea4fa66

Please sign in to comment.