feat: provide current opencart timezone to App
This commit is contained in:
@@ -7,7 +7,6 @@ use Cart\Currency;
|
||||
use Cart\Tax;
|
||||
use Monolog\Handler\RotatingFileHandler;
|
||||
use Monolog\Logger;
|
||||
use Openguru\OpenCartFramework\Http\Response as HttpResponse;
|
||||
use Openguru\OpenCartFramework\ImageTool\ImageTool;
|
||||
use Openguru\OpenCartFramework\ImageTool\ImageToolInterface;
|
||||
use Openguru\OpenCartFramework\OpenCart\Decorators\OcRegistryDecorator;
|
||||
@@ -41,69 +40,59 @@ class ControllerExtensionTgshopHandle extends Controller
|
||||
|
||||
public function index(): void
|
||||
{
|
||||
$bootstrapLogger = $this->createLogger();
|
||||
$this->session->data['language'] = $this->config->get('config_language');
|
||||
|
||||
try {
|
||||
$this->session->data['language'] = $this->config->get('config_language');
|
||||
|
||||
$json = $this->model_setting_setting->getSetting('module_telecart');
|
||||
if (! isset($json['module_telecart_settings'])) {
|
||||
$json['module_telecart_settings'] = [];
|
||||
}
|
||||
|
||||
$items = Arr::mergeArraysRecursively($json['module_telecart_settings'], [
|
||||
'app' => [
|
||||
'shop_base_url' => HTTPS_SERVER, // for catalog: HTTPS_SERVER, for admin: HTTPS_CATALOG
|
||||
'language_id' => (int) $this->config->get('config_language_id'),
|
||||
],
|
||||
'logs' => [
|
||||
'path' => DIR_LOGS,
|
||||
],
|
||||
'database' => [
|
||||
'host' => DB_HOSTNAME,
|
||||
'database' => DB_DATABASE,
|
||||
'username' => DB_USERNAME,
|
||||
'password' => DB_PASSWORD,
|
||||
'prefix' => DB_PREFIX,
|
||||
'port' => (int) DB_PORT,
|
||||
],
|
||||
'store' => [
|
||||
'oc_store_id' => 0,
|
||||
'oc_default_currency' => $this->config->get('config_currency'),
|
||||
'oc_config_tax' => filter_var($this->config->get('config_tax'), FILTER_VALIDATE_BOOLEAN),
|
||||
],
|
||||
'orders' => [
|
||||
'oc_customer_group_id' => (int) $this->config->get('config_customer_group_id'),
|
||||
],
|
||||
]);
|
||||
|
||||
$appDebug = Arr::get($items, 'app.app_debug');
|
||||
|
||||
$app = ApplicationFactory::create($items);
|
||||
|
||||
$app->bind(OcModelCatalogProductAdapter::class, function () {
|
||||
return new OcModelCatalogProductAdapter($this->model_catalog_product);
|
||||
});
|
||||
|
||||
$app->bind(Url::class, fn() => $this->url);
|
||||
$app->bind(Currency::class, fn() => $this->currency);
|
||||
$app->bind(Tax::class, fn() => $this->tax);
|
||||
$app->bind(ImageToolInterface::class, fn() => new ImageTool(DIR_IMAGE, HTTPS_SERVER));
|
||||
$app->bind(Cart::class, fn() => $this->cart);
|
||||
$app->bind(OcRegistryDecorator::class, fn() => new OcRegistryDecorator($this->registry));
|
||||
$app->singleton(Log::class, fn() => $this->log);
|
||||
|
||||
$app
|
||||
->withLogger(fn($app) => $this->createLogger($appDebug))
|
||||
->bootAndHandleRequest();
|
||||
} catch (Throwable $e) {
|
||||
$bootstrapLogger->error($e->getMessage(), ['exception' => $e]);
|
||||
http_response_code(HttpResponse::HTTP_INTERNAL_SERVER_ERROR);
|
||||
header('Content-Type: application/json');
|
||||
echo json_encode([
|
||||
'error' => 'Server Error.',
|
||||
], JSON_THROW_ON_ERROR);
|
||||
$json = $this->model_setting_setting->getSetting('module_telecart');
|
||||
if (! isset($json['module_telecart_settings'])) {
|
||||
$json['module_telecart_settings'] = [];
|
||||
}
|
||||
|
||||
$items = Arr::mergeArraysRecursively($json['module_telecart_settings'], [
|
||||
'app' => [
|
||||
'shop_base_url' => HTTPS_SERVER, // for catalog: HTTPS_SERVER, for admin: HTTPS_CATALOG
|
||||
'language_id' => (int)$this->config->get('config_language_id'),
|
||||
'timezone' => $this->config->get('config_timezone'),
|
||||
],
|
||||
'logs' => [
|
||||
'path' => DIR_LOGS,
|
||||
],
|
||||
'database' => [
|
||||
'host' => DB_HOSTNAME,
|
||||
'database' => DB_DATABASE,
|
||||
'username' => DB_USERNAME,
|
||||
'password' => DB_PASSWORD,
|
||||
'prefix' => DB_PREFIX,
|
||||
'port' => (int)DB_PORT,
|
||||
],
|
||||
'store' => [
|
||||
'oc_store_id' => 0,
|
||||
'oc_default_currency' => $this->config->get('config_currency'),
|
||||
'oc_config_tax' => filter_var($this->config->get('config_tax'), FILTER_VALIDATE_BOOLEAN),
|
||||
],
|
||||
'orders' => [
|
||||
'oc_customer_group_id' => (int)$this->config->get('config_customer_group_id'),
|
||||
],
|
||||
]);
|
||||
|
||||
$appDebug = Arr::get($items, 'app.app_debug');
|
||||
|
||||
$app = ApplicationFactory::create($items);
|
||||
|
||||
$app->bind(OcModelCatalogProductAdapter::class, function () {
|
||||
return new OcModelCatalogProductAdapter($this->model_catalog_product);
|
||||
});
|
||||
|
||||
$app->bind(Url::class, fn() => $this->url);
|
||||
$app->bind(Currency::class, fn() => $this->currency);
|
||||
$app->bind(Tax::class, fn() => $this->tax);
|
||||
$app->bind(ImageToolInterface::class, fn() => new ImageTool(DIR_IMAGE, HTTPS_SERVER));
|
||||
$app->bind(Cart::class, fn() => $this->cart);
|
||||
$app->bind(OcRegistryDecorator::class, fn() => new OcRegistryDecorator($this->registry));
|
||||
$app->singleton(Log::class, fn() => $this->log);
|
||||
|
||||
$app
|
||||
->withLogger(fn($app) => $this->createLogger($appDebug))
|
||||
->bootAndHandleRequest();
|
||||
}
|
||||
|
||||
function extractPureJs($input)
|
||||
|
||||
Reference in New Issue
Block a user