ver. 0.277: ShopProduct factory, Dashboard, Update migration, legacy cleanup, admin\App
- 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>
This commit is contained in:
31
autoload/admin/Controllers/DashboardController.php
Normal file
31
autoload/admin/Controllers/DashboardController.php
Normal file
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
namespace admin\Controllers;
|
||||
|
||||
use Domain\Dashboard\DashboardRepository;
|
||||
use Domain\ShopStatus\ShopStatusRepository;
|
||||
|
||||
class DashboardController
|
||||
{
|
||||
private DashboardRepository $repository;
|
||||
private ShopStatusRepository $statusesRepository;
|
||||
|
||||
public function __construct( DashboardRepository $repository, ShopStatusRepository $statusesRepository )
|
||||
{
|
||||
$this->repository = $repository;
|
||||
$this->statusesRepository = $statusesRepository;
|
||||
}
|
||||
|
||||
public function main_view(): string
|
||||
{
|
||||
return \Tpl::view( 'dashboard/main-view', [
|
||||
'last_orders' => $this->repository->lastOrders(),
|
||||
'order_statuses' => $this->statusesRepository->allStatuses(),
|
||||
'sales' => $this->repository->last24MonthsSales(),
|
||||
'best_sales_products' => $this->repository->bestSalesProducts(),
|
||||
'most_view_products' => $this->repository->mostViewedProducts(),
|
||||
'sales_grid' => $this->repository->salesGrid(),
|
||||
'summary_sales' => $this->repository->summarySales(),
|
||||
'summary_orders' => $this->repository->summaryOrders(),
|
||||
] );
|
||||
}
|
||||
}
|
||||
@@ -60,7 +60,7 @@ class ProductArchiveController
|
||||
$imageSrc = '/' . ltrim($imageSrc, '/');
|
||||
}
|
||||
|
||||
$categories = trim((string)\admin\factory\ShopProduct::product_categories($id));
|
||||
$categories = trim((string)$this->repository->productCategoriesText($id));
|
||||
$categoriesHtml = '';
|
||||
if ($categories !== '') {
|
||||
$categoriesHtml = '<small class="text-muted product-categories">'
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
49
autoload/admin/Controllers/UpdateController.php
Normal file
49
autoload/admin/Controllers/UpdateController.php
Normal file
@@ -0,0 +1,49 @@
|
||||
<?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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user