1
0
mirror of https://github.com/flarum/core.git synced 2025-10-13 07:54:25 +02:00

Backend cleanup (#2859)

* Extender docblocks cleanup
* Excplicit type hinting in extenders
* Bring method under constructor
* Mark some classes and methods as internal
* Remove beta references

Co-authored-by: Clark Winkelmann <clark.winkelmann@gmail.com>
This commit is contained in:
Sami Mazouz
2021-05-13 15:26:24 +01:00
committed by GitHub
parent e3f506817b
commit 7bceda976b
59 changed files with 655 additions and 174 deletions

View File

@@ -50,14 +50,6 @@ class Extension implements Arrayable
'jpg' => 'image/jpeg',
];
protected static function nameToId($name)
{
[$vendor, $package] = explode('/', $name);
$package = str_replace(['flarum-ext-', 'flarum-'], '', $package);
return "$vendor-$package";
}
/**
* Unique Id of the extension.
*
@@ -122,6 +114,14 @@ class Extension implements Arrayable
$this->assignId();
}
protected static function nameToId($name)
{
[$vendor, $package] = explode('/', $name);
$package = str_replace(['flarum-ext-', 'flarum-'], '', $package);
return "$vendor-$package";
}
/**
* Assigns the id for the extension used globally.
*/
@@ -130,6 +130,9 @@ class Extension implements Arrayable
$this->id = static::nameToId($this->name);
}
/**
* @internal
*/
public function extend(Container $container)
{
foreach ($this->getExtenders() as $extender) {
@@ -173,6 +176,8 @@ class Extension implements Arrayable
/**
* @param bool $installed
* @return Extension
*
* @internal
*/
public function setInstalled($installed)
{
@@ -192,6 +197,8 @@ class Extension implements Arrayable
/**
* @param string $version
* @return Extension
*
* @internal
*/
public function setVersion($version)
{
@@ -208,6 +215,8 @@ class Extension implements Arrayable
* are flarum extensions.
* @param array $enabledIds: An associative array where keys are the composer package names
* of enabled extensions. Used to figure out optional dependencies.
*
* @internal
*/
public function calculateDependencies($extensionSet, $enabledIds)
{
@@ -270,6 +279,9 @@ class Extension implements Arrayable
return $icon;
}
/**
* @internal
*/
public function enable(Container $container)
{
foreach ($this->getLifecycleExtenders() as $extender) {
@@ -277,6 +289,9 @@ class Extension implements Arrayable
}
}
/**
* @internal
*/
public function disable(Container $container)
{
foreach ($this->getLifecycleExtenders() as $extender) {
@@ -425,6 +440,9 @@ class Extension implements Arrayable
return realpath($this->path.'/assets/') !== false;
}
/**
* @internal
*/
public function copyAssetsTo(FilesystemInterface $target)
{
if (! $this->hasAssets()) {
@@ -451,6 +469,9 @@ class Extension implements Arrayable
return realpath($this->path.'/migrations/') !== false;
}
/**
* @internal
*/
public function migrate(Migrator $migrator, $direction = 'up')
{
if (! $this->hasMigrations()) {

View File

@@ -154,6 +154,8 @@ class ExtensionManager
* Enables the extension.
*
* @param string $name
*
* @internal
*/
public function enable($name)
{
@@ -194,6 +196,8 @@ class ExtensionManager
* Disables an extension.
*
* @param string $name
*
* @internal
*/
public function disable($name)
{
@@ -230,6 +234,7 @@ class ExtensionManager
* Uninstalls an extension.
*
* @param string $name
* @internal
*/
public function uninstall($name)
{
@@ -294,6 +299,8 @@ class ExtensionManager
* @param Extension $extension
* @param string $direction
* @return void
*
* @internal
*/
public function migrate(Extension $extension, $direction = 'up')
{
@@ -309,6 +316,8 @@ class ExtensionManager
*
* @param Extension $extension
* @return array Notes from the migrator.
*
* @internal
*/
public function migrateDown(Extension $extension)
{
@@ -419,6 +428,8 @@ class ExtensionManager
* to missing dependencies, in the format extension id => array of missing dependency IDs.
* 'circularDependencies' points to an array of extensions ids of extensions
* that cannot be processed due to circular dependencies
*
* @internal
*/
public static function resolveExtensionOrder($extensionList)
{