- Implemented CronJobProcessor for managing scheduled jobs and processing job queues. - Created CronJobRepository for database interactions related to cron jobs. - Defined CronJobType for job types, statuses, and backoff calculations. - Added ApiloLogger for logging actions related to API interactions. - Enhanced UpdateController to check for updates and display update logs. - Updated FormAction to include a preview action for forms. - Modified ApiRouter to handle new dependencies for OrderAdminService and ProductsApiController. - Extended DictionariesApiController to manage attributes and producers. - Enhanced ProductsApiController with variant management and image upload functionality. - Updated ShopBasketController and ShopProductController to sort attributes and handle custom fields. - Added configuration for cron jobs in config.php. - Initialized apilo-sync-queue.json for managing sync tasks.
66 lines
1.8 KiB
PHP
66 lines
1.8 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
|
|
{
|
|
$logContent = @file_get_contents( '../libraries/update_log.txt' );
|
|
|
|
return \Shared\Tpl\Tpl::view( 'update/main-view', [
|
|
'ver' => \Shared\Helpers\Helpers::get_version(),
|
|
'new_ver' => \Shared\Helpers\Helpers::get_new_version(),
|
|
'log' => $logContent ?: '',
|
|
] );
|
|
}
|
|
|
|
public function update(): void
|
|
{
|
|
$result = $this->repository->update();
|
|
|
|
if ( !$result['success'] ) {
|
|
\Shared\Helpers\Helpers::alert( 'W trakcie aktualizacji systemu wystąpił błąd. Proszę spróbować ponownie.' );
|
|
} else {
|
|
\Shared\Helpers\Helpers::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) \Shared\Helpers\Helpers::get( 'version_current' ) + 0.001, 3, '.', '' ),
|
|
];
|
|
|
|
echo json_encode( $response );
|
|
exit;
|
|
}
|
|
|
|
public function checkUpdate(): void
|
|
{
|
|
\Shared\Helpers\Helpers::set_session( 'new-version', null );
|
|
$newVer = \Shared\Helpers\Helpers::get_new_version();
|
|
$curVer = \Shared\Helpers\Helpers::get_version();
|
|
|
|
echo json_encode( [
|
|
'has_update' => $newVer > $curVer,
|
|
'new_ver' => $newVer,
|
|
] );
|
|
exit;
|
|
}
|
|
}
|