- ShopProduct factory: full migration (~40 ProductRepository methods, ~30 controller actions) - Dashboard: Domain+DI migration (DashboardRepository + DashboardController) - Update: Domain+DI migration (UpdateRepository + UpdateController, template rewrite) - Renamed admin\Site to admin\App, removed dead fallback routing - Removed all legacy folders: admin/controls, admin/factory, admin/view - Newsletter: switched from admin\factory\Articles to ArticleRepository - 414 tests, 1335 assertions passing Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
50 lines
1.2 KiB
PHP
50 lines
1.2 KiB
PHP
<?php
|
|
namespace admin\Controllers;
|
|
|
|
use Domain\Update\UpdateRepository;
|
|
|
|
class UpdateController
|
|
{
|
|
private UpdateRepository $repository;
|
|
|
|
public function __construct( UpdateRepository $repository )
|
|
{
|
|
$this->repository = $repository;
|
|
}
|
|
|
|
public function main_view(): string
|
|
{
|
|
return \Tpl::view( 'update/main-view', [
|
|
'ver' => \S::get_version(),
|
|
'new_ver' => \S::get_new_version(),
|
|
] );
|
|
}
|
|
|
|
public function update(): void
|
|
{
|
|
$result = $this->repository->update();
|
|
|
|
if ( !$result['success'] ) {
|
|
\S::alert( 'W trakcie aktualizacji systemu wystąpił błąd. Proszę spróbować ponownie.' );
|
|
} else {
|
|
\S::set_message( 'Aktualizacja przebiegła pomyślnie.' );
|
|
}
|
|
|
|
header( 'Location: /admin/update/main_view/' );
|
|
exit;
|
|
}
|
|
|
|
public function updateAll(): void
|
|
{
|
|
$result = $this->repository->update();
|
|
|
|
$response = [
|
|
'status' => !empty( $result['success'] ) && empty( $result['no_updates'] ),
|
|
'version' => number_format( (float) \S::get( 'version_current' ) + 0.001, 3, '.', '' ),
|
|
];
|
|
|
|
echo json_encode( $response );
|
|
exit;
|
|
}
|
|
}
|