[MODULES] Rename extensions to modules, add example plugin, change plugin location
This commit is contained in:
parent
596009c924
commit
0c79dfc67b
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -19,5 +19,3 @@
|
|||
!.php_cs
|
||||
/.php_cs.cache
|
||||
###< friendsofphp/php-cs-fixer ###
|
||||
|
||||
plugins/available
|
14
plugins/Test/Controller/TestController.php
Normal file
14
plugins/Test/Controller/TestController.php
Normal file
|
@ -0,0 +1,14 @@
|
|||
<?php
|
||||
|
||||
namespace App\Controller;
|
||||
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
|
||||
class TestController extends AbstractController
|
||||
{
|
||||
public function __invoke()
|
||||
{
|
||||
return new Response('<div style="background: #333; text: #999"> Test controller </div>');
|
||||
}
|
||||
}
|
15
plugins/Test/manifest.yaml
Normal file
15
plugins/Test/manifest.yaml
Normal file
|
@ -0,0 +1,15 @@
|
|||
info:
|
||||
name: 'Example'
|
||||
version: '0.1'
|
||||
author: 'Hugo Sales'
|
||||
homepage: '{project_url}'
|
||||
description: |
|
||||
Test plugin
|
||||
Description can use multiple lines
|
||||
|
||||
permissions:
|
||||
database:
|
||||
- 'table1': 'r'
|
||||
- 'table2': 'rw'
|
||||
filesystem:
|
||||
- 'folder': 'rw'
|
|
@ -1 +0,0 @@
|
|||
../available/Test/
|
|
@ -49,21 +49,21 @@ class Kernel extends BaseKernel
|
|||
{
|
||||
parent::__construct($environment, $debug);
|
||||
|
||||
if (!\defined('INSTALLDIR')) {
|
||||
if (!defined('INSTALLDIR')) {
|
||||
define('INSTALLDIR', dirname(__DIR__));
|
||||
define('SRCDIR', INSTALLDIR . '/src');
|
||||
define('PUBLICDIR', INSTALLDIR . '/public');
|
||||
define('GNUSOCIAL_ENGINE', 'GNU social');
|
||||
define('GS_ENGINE_NAME', 'GNU social');
|
||||
// MERGE Change to https://gnu.io/social/
|
||||
define('GNUSOCIAL_ENGINE_URL', 'https://gnusocial.network/');
|
||||
define('GS_PROJECT_URL', 'https://gnusocial.network/');
|
||||
// MERGE Change to https://git.gnu.io/gnu/gnu-social
|
||||
define('GNUSOCIAL_ENGINE_REPO_URL', 'https://notabug.org/diogo/gnu-social/');
|
||||
define('GS_REPOSITORY_URL', 'https://notabug.org/diogo/gnu-social/');
|
||||
// Current base version, major.minor.patch
|
||||
define('GNUSOCIAL_BASE_VERSION', '3.0.0');
|
||||
define('GS_BASE_VERSION', '3.0.0');
|
||||
// 'dev', 'alpha[0-9]+', 'beta[0-9]+', 'rc[0-9]+', 'release'
|
||||
define('GNUSOCIAL_LIFECYCLE', 'dev');
|
||||
define('GNUSOCIAL_VERSION', GNUSOCIAL_BASE_VERSION . '-' . GNUSOCIAL_LIFECYCLE);
|
||||
define('GNUSOCIAL_CODENAME', 'Big bang');
|
||||
define('GS_LIFECYCLE', 'dev');
|
||||
define('GS_VERSION', GS_BASE_VERSION . '-' . GS_LIFECYCLE);
|
||||
define('GS_CODENAME', 'Big bang');
|
||||
|
||||
// Work internally in UTC
|
||||
date_default_timezone_set('UTC');
|
||||
|
|
|
@ -68,14 +68,14 @@ class GNUsocial implements EventSubscriberInterface
|
|||
}
|
||||
|
||||
/**
|
||||
* Store these services to be accessed statically and load extensions
|
||||
* Store these services to be accessed statically and load modules
|
||||
*/
|
||||
public function register(EventDispatcherInterface $event_dispatcher): void
|
||||
{
|
||||
Log::setLogger($this->logger);
|
||||
GSEvent::setDispatcher($event_dispatcher);
|
||||
I18n::setTranslator($this->translator);
|
||||
ExtensionManager::loadExtensions();
|
||||
ModulesManager::loadModules();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -18,13 +18,13 @@
|
|||
*/
|
||||
|
||||
/**
|
||||
* Extension loader code, one of the main features of GNU social
|
||||
* Module and plugin loader code, one of the main features of GNU social
|
||||
*
|
||||
* Loads plugins from `plugins/enabled`, instances them
|
||||
* and hooks its events
|
||||
*
|
||||
* @package GNUsocial
|
||||
* @category Extensions
|
||||
* @category Modules
|
||||
*
|
||||
* @author Hugo Sales <hugo@fc.up.pt>
|
||||
* @copyright 2020 Free Software Foundation, Inc http://www.fsf.org
|
||||
|
@ -36,21 +36,21 @@ namespace App\Util;
|
|||
use App\Util\GSEvent as Event;
|
||||
use Functional as F;
|
||||
|
||||
abstract class ExtensionManager
|
||||
abstract class ModulesManager
|
||||
{
|
||||
public static array $extensions = [];
|
||||
public static array $modules = [];
|
||||
|
||||
public static function loadExtensions()
|
||||
public static function loadModules()
|
||||
{
|
||||
$plugins_paths = glob(INSTALLDIR . '/plugins/enabled/*');
|
||||
$plugins_paths = glob(INSTALLDIR . '/plugins/*');
|
||||
|
||||
foreach ($plugins_paths as $plugin_path) {
|
||||
$class_name = basename($plugin_path);
|
||||
$qualified = 'Plugin\\' . $class_name . '\\' . $class_name;
|
||||
|
||||
require_once $plugin_path . '/' . $class_name . '.php';
|
||||
$class = new $qualified;
|
||||
self::$extensions[] = $class;
|
||||
$class = new $qualified;
|
||||
self::$modules[] = $class;
|
||||
|
||||
// Register event handlers
|
||||
$methods = get_class_methods($class);
|
Loading…
Reference in New Issue
Block a user