- 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.
32 lines
811 B
PHP
32 lines
811 B
PHP
<?php
|
|
namespace admin\factory;
|
|
|
|
class Scontainers
|
|
{
|
|
private static function repository(): \Domain\Scontainers\ScontainersRepository
|
|
{
|
|
global $mdb;
|
|
return new \Domain\Scontainers\ScontainersRepository($mdb);
|
|
}
|
|
|
|
public static function container_delete($container_id)
|
|
{
|
|
return self::repository()->delete((int)$container_id);
|
|
}
|
|
|
|
public static function container_save($container_id, $title, $text, $status, $show_title)
|
|
{
|
|
return self::repository()->save([
|
|
'id' => (int)$container_id,
|
|
'title' => is_array($title) ? $title : [],
|
|
'text' => is_array($text) ? $text : [],
|
|
'status' => $status,
|
|
'show_title' => $show_title,
|
|
]);
|
|
}
|
|
|
|
public static function container_details($container_id)
|
|
{
|
|
return self::repository()->find((int)$container_id);
|
|
}
|
|
} |