ver. 0.273 - ShopProducer refactor + cleanup 6 factory facades
- Domain\Producer\ProducerRepository (CRUD + frontend) - admin\Controllers\ShopProducerController (DI) - Nowe widoki: producers-list, producer-edit (table-list/form-edit) - shop\Producer -> fasada do ProducerRepository - Przepiecie ShopProduct factory na TransportRepository - Usuniete 6 pustych factory facades: Languages, Newsletter, Scontainers, ShopProducer, ShopTransport, Layouts - Usuniete legacy: controls\ShopProducer, stare szablony - Testy: 338 tests, 1063 assertions OK
This commit is contained in:
@@ -1,51 +0,0 @@
|
||||
<?php
|
||||
namespace admin\factory;
|
||||
|
||||
class Languages
|
||||
{
|
||||
private static function repository(): \Domain\Languages\LanguagesRepository
|
||||
{
|
||||
global $mdb;
|
||||
return new \Domain\Languages\LanguagesRepository($mdb);
|
||||
}
|
||||
|
||||
public static function translation_delete($translation_id)
|
||||
{
|
||||
return self::repository()->deleteTranslation((int)$translation_id);
|
||||
}
|
||||
|
||||
public static function translation_save($translation_id, $text, $languages)
|
||||
{
|
||||
return self::repository()->saveTranslation((int)$translation_id, (string)$text, is_array($languages) ? $languages : []);
|
||||
}
|
||||
|
||||
public static function translation_details($translation_id)
|
||||
{
|
||||
return self::repository()->translationDetails((int)$translation_id);
|
||||
}
|
||||
|
||||
public static function language_delete($language_id)
|
||||
{
|
||||
return self::repository()->deleteLanguage((string)$language_id);
|
||||
}
|
||||
|
||||
public static function max_order()
|
||||
{
|
||||
return self::repository()->maxOrder();
|
||||
}
|
||||
|
||||
public static function language_save($language_id, $name, $status, $start, $o)
|
||||
{
|
||||
return self::repository()->saveLanguage((string)$language_id, (string)$name, $status, $start, (int)$o);
|
||||
}
|
||||
|
||||
public static function language_details($language_id)
|
||||
{
|
||||
return self::repository()->languageDetails((string)$language_id);
|
||||
}
|
||||
|
||||
public static function languages_list($only_active = false)
|
||||
{
|
||||
return self::repository()->languagesList((bool)$only_active);
|
||||
}
|
||||
}
|
||||
@@ -1,65 +0,0 @@
|
||||
<?php
|
||||
namespace admin\factory;
|
||||
|
||||
use Domain\Layouts\LayoutsRepository;
|
||||
use Domain\Pages\PagesRepository;
|
||||
|
||||
class Layouts
|
||||
{
|
||||
public static function layout_delete($layout_id)
|
||||
{
|
||||
return self::repository()->delete((int)$layout_id);
|
||||
}
|
||||
|
||||
public static function layout_details($layout_id)
|
||||
{
|
||||
return self::repository()->find((int)$layout_id);
|
||||
}
|
||||
|
||||
public static function layout_save(
|
||||
$layout_id,
|
||||
$name,
|
||||
$status,
|
||||
$pages,
|
||||
$html,
|
||||
$css,
|
||||
$js,
|
||||
$m_html,
|
||||
$m_css,
|
||||
$m_js,
|
||||
$categories,
|
||||
$categories_default
|
||||
) {
|
||||
return self::repository()->save([
|
||||
'id' => $layout_id,
|
||||
'name' => $name,
|
||||
'status' => $status,
|
||||
'pages' => $pages,
|
||||
'html' => $html,
|
||||
'css' => $css,
|
||||
'js' => $js,
|
||||
'm_html' => $m_html,
|
||||
'm_css' => $m_css,
|
||||
'm_js' => $m_js,
|
||||
'categories' => $categories,
|
||||
'categories_default' => $categories_default,
|
||||
]);
|
||||
}
|
||||
|
||||
public static function menus_list()
|
||||
{
|
||||
global $mdb;
|
||||
return (new PagesRepository($mdb))->menusWithPages();
|
||||
}
|
||||
|
||||
public static function layouts_list()
|
||||
{
|
||||
return self::repository()->listAll();
|
||||
}
|
||||
|
||||
private static function repository(): LayoutsRepository
|
||||
{
|
||||
global $mdb;
|
||||
return new LayoutsRepository($mdb);
|
||||
}
|
||||
}
|
||||
@@ -1,48 +0,0 @@
|
||||
<?php
|
||||
namespace admin\factory;
|
||||
|
||||
use Domain\Newsletter\NewsletterRepository;
|
||||
use Domain\Settings\SettingsRepository;
|
||||
|
||||
class Newsletter
|
||||
{
|
||||
public static function is_admin_template( $template_id )
|
||||
{
|
||||
return self::repository() -> isAdminTemplate( (int)$template_id );
|
||||
}
|
||||
|
||||
public static function newsletter_template_delete( $template_id )
|
||||
{
|
||||
return self::repository() -> deleteTemplate( (int)$template_id );
|
||||
}
|
||||
|
||||
public static function send( $dates, $template )
|
||||
{
|
||||
return self::repository() -> queueSend( (string)$dates, (int)$template );
|
||||
}
|
||||
|
||||
public static function email_template_detalis( $id_template )
|
||||
{
|
||||
return self::repository() -> templateDetails( (int)$id_template );
|
||||
}
|
||||
|
||||
public static function template_save( $id, $name, $text )
|
||||
{
|
||||
return self::repository() -> saveTemplate( (int)$id, (string)$name, (string)$text );
|
||||
}
|
||||
|
||||
public static function templates_list()
|
||||
{
|
||||
return self::repository() -> listTemplatesSimple( false );
|
||||
}
|
||||
|
||||
private static function repository(): NewsletterRepository
|
||||
{
|
||||
global $mdb;
|
||||
|
||||
return new NewsletterRepository(
|
||||
$mdb,
|
||||
new SettingsRepository($mdb)
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,32 +0,0 @@
|
||||
<?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);
|
||||
}
|
||||
}
|
||||
@@ -1,89 +0,0 @@
|
||||
<?
|
||||
namespace admin\factory;
|
||||
class ShopProducer
|
||||
{
|
||||
static public function all()
|
||||
{
|
||||
global $mdb;
|
||||
return $mdb -> select( 'pp_shop_producer', '*', [ 'ORDER' => [ 'name' => 'ASC' ] ] );
|
||||
}
|
||||
|
||||
static public function delete( int $producer_id )
|
||||
{
|
||||
global $mdb;
|
||||
return $mdb -> delete( 'pp_shop_producer', [ 'id' => $producer_id ] );
|
||||
}
|
||||
|
||||
static public function save( $producer_id, $name, int $status, $img, $description, $data, $meta_title )
|
||||
{
|
||||
global $mdb;
|
||||
|
||||
if ( !$producer_id )
|
||||
{
|
||||
$mdb -> insert( 'pp_shop_producer', [
|
||||
'name' => $name,
|
||||
'status' => $status,
|
||||
'img' => $img
|
||||
] );
|
||||
|
||||
$id = $mdb -> id();
|
||||
|
||||
$langs = ( new \Domain\Languages\LanguagesRepository( $mdb ) )->languagesList( true );
|
||||
foreach ( $langs as $lg )
|
||||
{
|
||||
$mdb -> insert( 'pp_shop_producer_lang', [
|
||||
'producer_id' => $id,
|
||||
'lang_id' => $lg['id'],
|
||||
'description' => $description[ $lg['id'] ] ?? null,
|
||||
'data' => $data[ $lg['id'] ] ?? null,
|
||||
'meta_title' => $meta_title[ $lg['id'] ] ?? null
|
||||
] );
|
||||
}
|
||||
|
||||
\S::htacces();
|
||||
\S::delete_dir( '../temp/' );
|
||||
|
||||
return $id;
|
||||
}
|
||||
else
|
||||
{
|
||||
$mdb -> update( 'pp_shop_producer', [
|
||||
'name' => $name,
|
||||
'status' => $status,
|
||||
'img' => $img
|
||||
], [
|
||||
'id' => (int) $producer_id
|
||||
] );
|
||||
|
||||
$langs = ( new \Domain\Languages\LanguagesRepository( $mdb ) )->languagesList( true );
|
||||
foreach ( $langs as $lg )
|
||||
{
|
||||
if ( $translation_id = $mdb -> get( 'pp_shop_producer_lang', 'id', [ 'AND' => [ 'producer_id' => $producer_id, 'lang_id' => $lg['id'] ] ] ) )
|
||||
{
|
||||
$mdb -> update( 'pp_shop_producer_lang', [
|
||||
'description' => $description[ $lg['id'] ] ?? null,
|
||||
'meta_title' => $meta_title[ $lg['id'] ] ?? null,
|
||||
'data' => $data[ $lg['id'] ] ?? null
|
||||
], [
|
||||
'id' => $translation_id
|
||||
] );
|
||||
}
|
||||
else
|
||||
{
|
||||
$mdb -> insert( 'pp_shop_producer_lang', [
|
||||
'producer_id' => $producer_id,
|
||||
'lang_id' => $lg['id'],
|
||||
'description' => $description[ $lg['id'] ] ?? null,
|
||||
'data' => $data[ $lg['id'] ] ?? null,
|
||||
'meta_title' => $meta_title[ $lg['id'] ] ?? null
|
||||
] );
|
||||
}
|
||||
}
|
||||
|
||||
\S::htacces();
|
||||
\S::delete_dir( '../temp/' );
|
||||
return $producer_id;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -397,7 +397,7 @@ class ShopProduct
|
||||
$p_gshipping = $itemNode -> appendChild( $doc -> createElement( 'g:shipping' ) );
|
||||
$p_gcountry = $p_gshipping -> appendChild( $doc -> createElement( 'g:country', 'PL' ) );
|
||||
$p_gservice = $p_gshipping -> appendChild( $doc -> createElement( 'g:service', '1 dzień roboczy' ) );
|
||||
$p_gprice = $p_gshipping -> appendChild( $doc -> createElement( 'g:price', \admin\factory\ShopTransport::lowest_transport_price( (int) $product -> wp ) . ' PLN' ) );
|
||||
$p_gprice = $p_gshipping -> appendChild( $doc -> createElement( 'g:price', ( new \Domain\Transport\TransportRepository( $mdb ) )->lowestTransportPrice( (int) $product -> wp ) . ' PLN' ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -484,7 +484,7 @@ class ShopProduct
|
||||
$p_gshipping = $itemNode -> appendChild( $doc -> createElement( 'g:shipping' ) );
|
||||
$p_gcountry = $p_gshipping -> appendChild( $doc -> createElement( 'g:country', 'PL' ) );
|
||||
$p_gservice = $p_gshipping -> appendChild( $doc -> createElement( 'g:service', '1 dzień roboczy' ) );
|
||||
$p_gprice = $p_gshipping -> appendChild( $doc -> createElement( 'g:price', \admin\factory\ShopTransport::lowest_transport_price( (int) $product -> wp ) . ' PLN' ) );
|
||||
$p_gprice = $p_gshipping -> appendChild( $doc -> createElement( 'g:price', ( new \Domain\Transport\TransportRepository( $mdb ) )->lowestTransportPrice( (int) $product -> wp ) . ' PLN' ) );
|
||||
}
|
||||
}
|
||||
file_put_contents('../google-feed.xml', $doc -> saveXML());
|
||||
|
||||
@@ -1,10 +0,0 @@
|
||||
<?php
|
||||
namespace admin\factory;
|
||||
class ShopTransport
|
||||
{
|
||||
public static function lowest_transport_price( $wp ) {
|
||||
global $mdb;
|
||||
$repo = new \Domain\Transport\TransportRepository($mdb);
|
||||
return $repo->lowestTransportPrice($wp);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user