Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Update Manager Refactor #1259

Draft
wants to merge 7 commits into
base: wip/support-uploading-packages
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,14 @@
"source": "https://github.com/wintercms/winter"
},
"require": {
"php": "^8.0.2",
"php": "^8.1",
"winter/storm": "dev-develop as 1.2",
"winter/wn-system-module": "dev-develop",
"winter/wn-backend-module": "dev-develop",
"winter/wn-cms-module": "dev-develop",
"laravel/framework": "^9.1",
"wikimedia/composer-merge-plugin": "~2.1.0"
"wikimedia/composer-merge-plugin": "~2.1.0",
"winter/packager": "*"
},
"require-dev": {
"phpunit/phpunit": "^9.5.8",
Expand Down
2 changes: 1 addition & 1 deletion modules/backend/classes/AuthManager.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php namespace Backend\Classes;

use Config;
use System\Classes\PluginManager;
use System\Classes\Extensions\PluginManager;
use Winter\Storm\Auth\Manager as StormAuthManager;
use Winter\Storm\Exception\SystemException;

Expand Down
2 changes: 1 addition & 1 deletion modules/backend/classes/BackendController.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
use Request;
use Response;
use Str;
use System\Classes\PluginManager;
use System\Classes\Extensions\PluginManager;
use View;
use Winter\Storm\Router\Helper as RouterHelper;

Expand Down
10 changes: 5 additions & 5 deletions modules/backend/classes/NavigationManager.php
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
<?php namespace Backend\Classes;

use Event;
use BackendAuth;
use System\Classes\PluginManager;
use Validator;
use SystemException;
use Log;
use Config;
use Event;
use Log;
use System\Classes\Extensions\PluginManager;
use SystemException;
use Validator;

/**
* Manages the backend navigation.
Expand Down
6 changes: 3 additions & 3 deletions modules/backend/classes/WidgetManager.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<?php namespace Backend\Classes;

use Str;
use BackendAuth;
use SystemException;
use System\Classes\PluginManager;
use Event;
use Str;
use System\Classes\Extensions\PluginManager;
use SystemException;

/**
* Widget manager
Expand Down
26 changes: 13 additions & 13 deletions modules/backend/widgets/Lists.php
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
<?php namespace Backend\Widgets;

use ApplicationException;
use Backend;
use Backend\Classes\ListColumn;
use Backend\Classes\WidgetBase;
use BackendAuth;
use Carbon\Carbon;
use Db;
use Str;
use DbDongle;
use Html;
use Lang;
use Backend;
use DbDongle;
use Carbon\Carbon;
use Winter\Storm\Html\Helper as HtmlHelper;
use Winter\Storm\Router\Helper as RouterHelper;
use System\Helpers\DateTime as DateTimeHelper;
use System\Classes\PluginManager;
use System\Classes\MediaLibrary;
use Str;
use System\Classes\Extensions\PluginManager;
use System\Classes\ImageResizer;
use Backend\Classes\ListColumn;
use Backend\Classes\WidgetBase;
use System\Classes\MediaLibrary;
use System\Helpers\DateTime as DateTimeHelper;
use Winter\Storm\Database\Model;
use ApplicationException;
use BackendAuth;
use Winter\Storm\Html\Helper as HtmlHelper;
use Winter\Storm\Router\Helper as RouterHelper;

/**
* List Widget
Expand Down
4 changes: 2 additions & 2 deletions modules/cms/classes/ComponentManager.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<?php namespace Cms\Classes;

use Illuminate\Support\Facades\App;
use Str;
use System\Classes\PluginManager;
use System\Classes\Extensions\PluginManager;
use SystemException;
use Illuminate\Support\Facades\App;

/**
* Component manager
Expand Down
38 changes: 37 additions & 1 deletion modules/cms/classes/Theme.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
use Illuminate\Support\Facades\App;
use Illuminate\Support\Facades\Cache;
use Illuminate\Support\Facades\Lang;
use System\Classes\Extensions\WinterExtension;
use System\Models\Parameter;
use Winter\Storm\Exception\ApplicationException;
use Winter\Storm\Exception\SystemException;
Expand All @@ -29,7 +30,7 @@
* @package winter\wn-cms-module
* @author Alexey Bobkov, Samuel Georges
*/
class Theme extends CmsObject
class Theme extends CmsObject implements WinterExtension
{
/**
* @var string Specifies the theme directory name.
Expand Down Expand Up @@ -713,4 +714,39 @@ public function __isset($key)

return false;
}

public function extensionInstall(): static
{
// TODO: Implement extensionInstall() method.
}

public function extensionUninstall(): static
{
// TODO: Implement extensionUninstall() method.
}

public function extensionEnable(): static
{
// TODO: Implement extensionEnable() method.
}

public function extensionDisable(): static
{
// TODO: Implement extensionDisable() method.
}

public function extensionRollback(): static
{
// TODO: Implement extensionRollback() method.
}

public function extensionRefresh(): static
{
// TODO: Implement extensionRefresh() method.
}

public function extensionUpdate(): static
{
// TODO: Implement extensionUpdate() method.
}
}
91 changes: 74 additions & 17 deletions modules/cms/classes/ThemeManager.php
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
<?php namespace Cms\Classes;
<?php

use File;
use ApplicationException;
namespace Cms\Classes;

use System\Classes\Extensions\ExtensionManagerInterface;
use System\Classes\Extensions\Source\ExtensionSource;
use System\Classes\Extensions\WinterExtension;
use System\Models\Parameter;
use Cms\Classes\Theme as CmsTheme;
use Winter\Storm\Exception\ApplicationException;
use Winter\Storm\Support\Facades\File;

/**
* Theme manager
*
* @package winter\wn-cms-module
* @author Alexey Bobkov, Samuel Georges
*/
class ThemeManager
class ThemeManager implements ExtensionManagerInterface
{
use \Winter\Storm\Support\Traits\Singleton;

//
// Gateway spawned
//

/**
* Returns a collection of themes installed via the update gateway
* @return array
Expand All @@ -33,7 +33,7 @@ public function getInstalled()
* @param string $name Theme code
* @return boolean
*/
public function isInstalled($name)
public function isInstalled($name): bool
{
return array_key_exists($name, Parameter::get('system::theme.history', []));
}
Expand Down Expand Up @@ -84,23 +84,66 @@ public function findByDirName($dirName)
return null;
}

//
// Management
//
public function list(): array
{
// TODO: Implement list() method.
return [];
}

public function create(string $extension): Theme
{
// TODO: Implement create() method.
}

public function install(ExtensionSource|WinterExtension|string $extension): Theme
{
// TODO: Implement install() method.
}

public function get(WinterExtension|ExtensionSource|string $extension): ?WinterExtension
{
// TODO: Implement getExtension() method.
}

public function enable(WinterExtension|string $extension, string|bool $flag = self::DISABLED_BY_USER): Theme
{
// TODO: Implement enable() method.
}

public function disable(WinterExtension|string $extension, string|bool $flag = self::DISABLED_BY_USER): Theme
{
// TODO: Implement disable() method.
}

public function update(WinterExtension|string $extension): Theme
{
// TODO: Implement update() method.
}

public function refresh(WinterExtension|string $extension): Theme
{
// TODO: Implement refresh() method.
}

public function rollback(WinterExtension|string $extension, string $targetVersion): Theme
{
// TODO: Implement rollback() method.
}

/**
* Completely delete a theme from the system.
* @param string $theme Theme code/namespace
* @return void
* @param WinterExtension|string $theme Theme code/namespace
* @return mixed
* @throws ApplicationException
*/
public function deleteTheme($theme)
public function uninstall(WinterExtension|string $theme): mixed
{
if (!$theme) {
return false;
}

if (is_string($theme)) {
$theme = CmsTheme::load($theme);
$theme = Theme::load($theme);
}

if ($theme->isActiveTheme()) {
Expand All @@ -123,5 +166,19 @@ public function deleteTheme($theme)
if ($themeCode = $this->findByDirName($theme->getDirName())) {
$this->setUninstalled($themeCode);
}

return true;
}

/**
* @deprecated TODO: Remove this
*
* @param $theme
* @return mixed
* @throws ApplicationException
*/
public function deleteTheme($theme): mixed
{
return $this->uninstall($theme);
}
}
3 changes: 2 additions & 1 deletion modules/cms/console/ThemeInstall.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
use Cms\Classes\Theme;
use Cms\Classes\ThemeManager;
use File;
use System\Classes\Core\MarketPlaceApi;
use System\Classes\UpdateManager;
use Winter\Storm\Console\Command;

Expand Down Expand Up @@ -63,7 +64,7 @@ public function handle()
$themeManager = ThemeManager::instance();
$updateManager = UpdateManager::instance();

$themeDetails = $updateManager->requestThemeDetails($themeName);
$themeDetails = MarketPlaceApi::instance()->request(MarketPlaceApi::REQUEST_THEME_DETAIL, $themeName);

if ($themeManager->isInstalled($themeDetails['code'])) {
return $this->error(sprintf('The theme %s is already installed.', $themeDetails['code']));
Expand Down
10 changes: 5 additions & 5 deletions modules/cms/widgets/ComponentList.php
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
<?php namespace Cms\Widgets;

use App;
use Str;
use Lang;
use Input;
use System\Classes\PluginManager;
use Cms\Classes\ComponentHelpers;
use Backend\Classes\WidgetBase;
use Cms\Classes\ComponentHelpers;
use Input;
use Lang;
use Str;
use System\Classes\Extensions\PluginManager;

/**
* Component list widget.
Expand Down
11 changes: 8 additions & 3 deletions modules/system/ServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,15 @@
use Illuminate\Pagination\Paginator;
use Illuminate\Support\Facades\Config;
use Illuminate\Support\Facades\Request;
use Illuminate\Support\Facades\Schema;
use Illuminate\Support\Facades\View;
use System\Classes\CombineAssets;
use System\Classes\ErrorHandler;
use System\Classes\Extensions\PluginManager;
use System\Classes\FileManifest;
use System\Classes\MailManager;
use System\Classes\MarkupManager;
use System\Classes\PluginManager;
use System\Classes\SettingsManager;
use System\Classes\SourceManifest;
use System\Classes\UpdateManager;
use System\Helpers\DateTime;
use System\Models\EventLog;
Expand Down Expand Up @@ -146,6 +147,10 @@ protected function registerSingletons()

// Register the Laravel Vite singleton
$this->app->singleton(LaravelVite::class, \System\Classes\Asset\Vite::class);

// @TODO: Document
$this->app->bind(SourceManifest::class, SourceManifest::class);
$this->app->bind(FileManifest::class, FileManifest::class);
}

/**
Expand Down Expand Up @@ -179,7 +184,7 @@ protected function registerPrivilegedActions()
// @see octobercms/october#3208
|| (
$this->app->hasDatabase()
&& !Schema::hasTable(UpdateManager::instance()->getMigrationTableName())
&& !UpdateManager::instance()->isSystemSetup()
)
)
) {
Expand Down
4 changes: 4 additions & 0 deletions modules/system/aliases.php
Original file line number Diff line number Diff line change
Expand Up @@ -111,4 +111,8 @@
'October\Rain\Scaffold\Console\CreateReportWidget' => Backend\Console\CreateReportWidget::class,
'October\Rain\Scaffold\Console\CreateTheme' => Cms\Console\CreateTheme::class,
'October\Rain\Scaffold\Console\CreateComponent' => Cms\Console\CreateComponent::class,

// Extension Management
'System\Classes\PluginManager' => System\Classes\Extensions\PluginManager::class,
'System\Classes\PluginBase' => System\Classes\Extensions\PluginBase::class,
];
Loading
Loading