Dodaj obsługę punktów Orlen w zamówieniach oraz popraw styl i logikę w szablonach

This commit is contained in:
2024-11-16 10:56:46 +01:00
parent 3cbf8842ab
commit 6c09a26b0d
24 changed files with 917 additions and 413 deletions

View File

@@ -1,30 +1,53 @@
<?
class RedisConnection {
<?php
class RedisConnection
{
private static $instance = null;
private $redis;
private function __construct() {
private function __construct()
{
global $config;
$this -> redis = new \Redis();
if ( !$this -> redis -> connect( $config['redis']['host'], $config['redis']['port'] ) ) {
throw new Exception("Nie udało się połączyć z serwerem Redis.");
$this->redis = new \Redis();
try
{
// Próba połączenia z serwerem Redis
if (!$this->redis->connect($config['redis']['host'], $config['redis']['port']))
{
// Logowanie błędu bez rzucania wyjątku
error_log("Nie udało się połączyć z serwerem Redis.");
$this->redis = null;
return;
}
// Autentykacja za pomocą hasła
if ( !$this -> redis -> auth( $config['redis']['password'] ) ) {
// Próba autoryzacji
if (!$this->redis->auth($config['redis']['password']))
{
error_log("Autoryzacja do serwera Redis nie powiodła się.");
$this->redis = null;
return;
}
}
catch (\Exception $e)
{
// Obsługa wyjątków, bez rzucania błędu
error_log("Błąd podczas połączenia z Redis: " . $e->getMessage());
$this->redis = null;
}
}
public static function getInstance() {
if ( self::$instance === null ) {
public static function getInstance()
{
if (self::$instance === null)
{
self::$instance = new self();
}
return self::$instance;
}
public function getConnection() {
public function getConnection()
{
return $this->redis;
}
}