feat: Add Transport module with repository, controller, and views

- Implemented TransportRepository for managing transport data with methods for listing, finding, saving, and retrieving transport costs.
- Created ShopTransportController to handle transport-related actions, including listing, editing, and saving transports.
- Added views for transport management: transports list and transport edit forms.
- Introduced JavaScript for responsive tabs in transport edit view.
- Updated testing suite with comprehensive unit tests for TransportRepository and ShopTransportController.
- Increased test coverage with new assertions and scenarios for transport functionalities.
This commit is contained in:
2026-02-14 20:16:18 +01:00
parent 818cd7f2c0
commit 7468dd0d3f
20 changed files with 1215 additions and 377 deletions

View File

@@ -2,11 +2,11 @@
namespace front\factory;
class ShopTransport
{
// get_apilo_carrier_account_id
static public function get_apilo_carrier_account_id( $transport_method_id )
{
global $mdb;
return $mdb -> get( 'pp_shop_transports', 'apilo_carrier_account_id', [ 'id' => $transport_method_id ] );
$repo = new \Domain\Transport\TransportRepository($mdb);
return $repo->getApiloCarrierAccountId($transport_method_id);
}
public static function transport_methods( $basket, $coupon )
@@ -20,14 +20,8 @@ class ShopTransport
if ( !$objectData )
{
$results = $mdb -> query( 'SELECT '
. 'pst.id, name, name_visible, description, cost, max_wp, pst.default, delivery_free '
. 'FROM '
. 'pp_shop_transports AS pst '
. 'WHERE '
. 'status = 1 ORDER BY o ASC' ) -> fetchAll( \PDO::FETCH_ASSOC );
if ( is_array( $results ) and !empty( $results ) ) foreach ( $results as $row )
$transports_tmp[] = $row;
$repo = new \Domain\Transport\TransportRepository($mdb);
$transports_tmp = $repo->allActive();
$cacheHandler -> set( $cacheKey, $transports_tmp );
}
@@ -65,11 +59,8 @@ class ShopTransport
if ( !$cost = \Cache::fetch( 'transport_cost_' . $transport_id ) )
{
$cost = $mdb -> get( 'pp_shop_transports', 'cost', [
'AND' => [
'id' => $transport_id,
'status' => 1
] ] );
$repo = new \Domain\Transport\TransportRepository($mdb);
$cost = $repo->getTransportCost($transport_id);
\Cache::store( 'transport_cost_' . $transport_id, $cost );
}
@@ -82,11 +73,8 @@ class ShopTransport
if ( !$transport = \Cache::fetch( 'transport' . $transport_id ) )
{
$transport = $mdb -> get( 'pp_shop_transports', '*', [
'AND' => [
'id' => $transport_id,
'status' => 1
] ] );
$repo = new \Domain\Transport\TransportRepository($mdb);
$transport = $repo->findActiveById($transport_id);
\Cache::store( 'transport' . $transport_id, $transport );
}