Files
shopPRO/autoload/front/factory/class.Scontainers.php
Jacek Pyziak 42e4396064 Refactor Scontainers management
- Removed legacy Scontainers controller and view files, transitioning to a new controller structure.
- Introduced ScontainersController to handle CRUD operations with improved dependency injection.
- Created ScontainersRepository for database interactions, encapsulating logic for container management.
- Updated container edit and list views to utilize new templating system.
- Added unit tests for ScontainersRepository and ScontainersController to ensure functionality.
- Enhanced form handling for container editing, including validation and error management.
2026-02-12 23:54:56 +01:00

39 lines
931 B
PHP

<?php
namespace front\factory;
class Scontainers
{
public static function scontainer_details($scontainer_id)
{
global $mdb, $lang;
$cacheHandler = new \CacheHandler();
$cacheKey = "\front\factory\Scontainers::scontainer_details:$scontainer_id";
$objectData = $cacheHandler->get($cacheKey);
if ($objectData) {
return unserialize($objectData);
}
$repository = new \Domain\Scontainers\ScontainersRepository($mdb);
$langId = (string)($lang[0] ?? 'pl');
$scontainer = $repository->detailsForLanguage((int)$scontainer_id, $langId);
if (!is_array($scontainer)) {
$scontainer = [
'id' => (int)$scontainer_id,
'status' => 0,
'show_title' => 0,
'languages' => [
'lang_id' => $langId,
'title' => '',
'text' => '',
],
];
}
$cacheHandler->set($cacheKey, $scontainer);
return $scontainer;
}
}