ver. 0.288: BasketCalculator + ShopBasketController migration, cms\Layout removal

- Migrate front\factory\ShopBasket → Domain\Basket\BasketCalculator (4 static methods, 18 callers updated)
- Migrate front\controls\ShopBasket → front\Controllers\ShopBasketController (camelCase, instance methods)
- Add snake_case→camelCase action dispatch for new controllers in Site::route()
- Update title()/page_title() to check front\Controllers\ before fallback
- Remove cms\Layout class (replaced by $layoutsRepo->find())
- Add 8 tests for BasketCalculator (484 tests, 1528 assertions)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-02-17 09:38:45 +01:00
parent a7e44f23fa
commit 25348797da
22 changed files with 287 additions and 275 deletions

View File

@@ -5,30 +5,34 @@ class Site
{
static public function page_title()
{
$class = '\front\controls\\';
$moduleName = implode( '', array_map( 'ucfirst', explode( '_', \Shared\Helpers\Helpers::get( 'module' ) ) ) );
$action = \Shared\Helpers\Helpers::get( 'action' );
$actionCamel = lcfirst( implode( '', array_map( 'ucfirst', explode( '_', $action ) ) ) );
$results = explode( '_', \Shared\Helpers\Helpers::get( 'module' ) );
if ( is_array( $results ) ) foreach ( $results as $row )
$class .= ucfirst( $row );
$controllerClass = '\front\Controllers\\' . $moduleName . 'Controller';
if ( class_exists( $controllerClass ) and property_exists( $controllerClass, 'title' ) and isset( $controllerClass::$title[$actionCamel] ) )
return $controllerClass::$title[$actionCamel];
$property = \Shared\Helpers\Helpers::get( 'action' );
$class = '\front\controls\\' . $moduleName;
if ( class_exists( $class ) and property_exists( new $class, 'page_title' ) )
return $class::$title[$property];
return $class::$title[$action];
}
static public function title()
{
global $settings;
$class = '\front\controls\\';
$moduleName = implode( '', array_map( 'ucfirst', explode( '_', \Shared\Helpers\Helpers::get( 'module' ) ) ) );
$action = \Shared\Helpers\Helpers::get( 'action' );
$actionCamel = lcfirst( implode( '', array_map( 'ucfirst', explode( '_', $action ) ) ) );
$results = explode( '_', \Shared\Helpers\Helpers::get( 'module' ) );
if ( is_array( $results ) ) foreach ( $results as $row )
$class .= ucfirst( $row );
$controllerClass = '\front\Controllers\\' . $moduleName . 'Controller';
if ( class_exists( $controllerClass ) and property_exists( $controllerClass, 'title' ) and isset( $controllerClass::$title[$actionCamel] ) )
return $controllerClass::$title[$actionCamel] . ' | ' . $settings['firm_name'];
$property = \Shared\Helpers\Helpers::get( 'action' );
$class = '\front\controls\\' . $moduleName;
if ( class_exists( $class ) and property_exists( new $class, 'title' ) )
return $class::$title[$property] . ' | ' . $settings['firm_name'];
return $class::$title[$action] . ' | ' . $settings['firm_name'];
}
public static function route( $product = '', $category = '' )
@@ -64,8 +68,9 @@ class Site
if ( isset( $controllerFactories[$moduleName] ) and $action )
{
$controller = $controllerFactories[$moduleName]();
if ( method_exists( $controller, $action ) )
return $controller->$action();
$actionCamel = lcfirst( implode( '', array_map( 'ucfirst', explode( '_', $action ) ) ) );
if ( method_exists( $controller, $actionCamel ) )
return $controller->$actionCamel();
}
// stare klasy
@@ -162,6 +167,9 @@ class Site
new \Domain\Newsletter\NewsletterRepository( $mdb )
);
},
'ShopBasket' => function() {
return new \front\Controllers\ShopBasketController();
},
];
}
}