feat(domain): Domain\Scontainers + Domain\Banners repositories z wrapper delegation
Phase 3 complete: - ScontainersRepository: containerDetails, containerSave, containerDelete, scontainerByLang - BannersRepository: bannerDetails, bannerSave, bannerDelete, activeBanners, mainBanner - 4 legacy factories converted to thin wrappers delegating to Domain repos Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -7,115 +7,21 @@ class Scontainers
|
||||
public static function container_delete( $container_id )
|
||||
{
|
||||
global $mdb;
|
||||
return $mdb -> delete( 'pp_scontainers', [ 'id' => (int) $container_id ] );
|
||||
$repo = new \Domain\Scontainers\ScontainersRepository($mdb);
|
||||
return $repo->containerDelete($container_id);
|
||||
}
|
||||
|
||||
public static function container_save( $container_id, $title, $text, $status, $show_title, $src, $html )
|
||||
{
|
||||
global $mdb;
|
||||
|
||||
if ( !$container_id )
|
||||
{
|
||||
$mdb -> insert( 'pp_scontainers',
|
||||
[
|
||||
'status' => $status == 'on' ? 1 : 0,
|
||||
'show_title' => $show_title == 'on' ? 1 : 0,
|
||||
'src' => $src
|
||||
] );
|
||||
|
||||
$id = $mdb -> id();
|
||||
|
||||
if ( $id )
|
||||
{
|
||||
$i = 0;
|
||||
|
||||
$results = $mdb -> select( 'pp_langs', [ 'id' ], [ 'status' => 1, 'ORDER' => [ 'o' => 'ASC' ] ] );
|
||||
if ( is_array( $results ) and count( $results ) > 1 ) foreach ( $results as $row )
|
||||
{
|
||||
$mdb -> insert( 'pp_scontainers_langs',
|
||||
[
|
||||
'container_id' => (int) $id,
|
||||
'lang_id' => $row['id'],
|
||||
'title' => $title[$i],
|
||||
'text' => $text[$i],
|
||||
'html' => $html[$i]
|
||||
] );
|
||||
$i++;
|
||||
}
|
||||
else if ( is_array( $results ) and count( $results ) == 1 ) foreach ( $results as $row )
|
||||
{
|
||||
$mdb -> insert( 'pp_scontainers_langs', [
|
||||
'container_id' => (int) $id,
|
||||
'lang_id' => $row['id'],
|
||||
'title' => $title,
|
||||
'text' => $text,
|
||||
'html' => $html
|
||||
] );
|
||||
}
|
||||
|
||||
\S::delete_cache();
|
||||
|
||||
return $id;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$mdb -> update( 'pp_scontainers',
|
||||
[
|
||||
'status' => $status == 'on' ? 1 : 0,
|
||||
'show_title' => $show_title == 'on' ? 1 : 0,
|
||||
'src' => $src
|
||||
],
|
||||
[
|
||||
'id' => (int) $container_id
|
||||
] );
|
||||
|
||||
$mdb -> delete( 'pp_scontainers_langs',
|
||||
[ 'container_id' => (int) $container_id ] );
|
||||
|
||||
$i = 0;
|
||||
|
||||
$results = $mdb -> select( 'pp_langs', [ 'id' ], [ 'status' => 1, 'ORDER' => [ 'o' => 'ASC' ] ] );
|
||||
if ( is_array( $results ) and count( $results ) > 1 ) foreach ( $results as $row )
|
||||
{
|
||||
$mdb -> insert( 'pp_scontainers_langs',
|
||||
[
|
||||
'container_id' => (int) $container_id,
|
||||
'lang_id' => $row['id'],
|
||||
'title' => $title[$i],
|
||||
'text' => $text[$i],
|
||||
'html' => $html[$i]
|
||||
] );
|
||||
$i++;
|
||||
}
|
||||
else if ( is_array( $results ) and count( $results ) == 1 ) foreach ( $results as $row )
|
||||
{
|
||||
$mdb -> insert( 'pp_scontainers_langs',
|
||||
[
|
||||
'container_id' => (int) $container_id,
|
||||
'lang_id' => $row['id'],
|
||||
'title' => $title,
|
||||
'text' => $text,
|
||||
'html' => $html
|
||||
] );
|
||||
}
|
||||
|
||||
\S::delete_cache();
|
||||
|
||||
return $container_id;
|
||||
}
|
||||
$repo = new \Domain\Scontainers\ScontainersRepository($mdb);
|
||||
return $repo->containerSave($container_id, $title, $text, $status, $show_title, $src, $html);
|
||||
}
|
||||
|
||||
public static function container_details( $container_id )
|
||||
{
|
||||
global $mdb;
|
||||
|
||||
$container = $mdb -> get( 'pp_scontainers', '*', [ 'id' => (int) $container_id ] );
|
||||
|
||||
$results = $mdb -> select( 'pp_scontainers_langs', '*', [ 'container_id' => (int) $container_id ] );
|
||||
if ( is_array( $results ) ) foreach ( $results as $row )
|
||||
$container['languages'][$row['lang_id']] = $row;
|
||||
|
||||
return $container;
|
||||
$repo = new \Domain\Scontainers\ScontainersRepository($mdb);
|
||||
return $repo->containerDetails($container_id);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user