Add view classes for articles, banners, languages, menu, newsletter, containers, shop categories, clients, payment methods, products, and search
- Created Articles.php for rendering article views including full articles, miniature lists, and news sections. - Added Banners.php for handling banner displays. - Introduced Languages.php for rendering language options. - Implemented Menu.php for dynamic menu rendering. - Developed Newsletter.php for newsletter view rendering. - Created Scontainers.php for rendering specific containers. - Added ShopCategory.php for category descriptions and product listings. - Introduced ShopClient.php for managing client-related views such as address editing and order history. - Implemented ShopPaymentMethod.php for displaying payment methods in the basket. - Created ShopProduct.php for generating product URLs. - Added ShopSearch.php for rendering a simple search form. - Added .htaccess file to enhance security by restricting access to sensitive files and directories.
This commit is contained in:
82
autoload/api/Controllers/DictionariesApiController.php
Normal file
82
autoload/api/Controllers/DictionariesApiController.php
Normal file
@@ -0,0 +1,82 @@
|
||||
<?php
|
||||
namespace api\Controllers;
|
||||
|
||||
use api\ApiRouter;
|
||||
use Domain\ShopStatus\ShopStatusRepository;
|
||||
use Domain\Transport\TransportRepository;
|
||||
use Domain\PaymentMethod\PaymentMethodRepository;
|
||||
|
||||
class DictionariesApiController
|
||||
{
|
||||
private $statusRepo;
|
||||
private $transportRepo;
|
||||
private $paymentRepo;
|
||||
|
||||
public function __construct(
|
||||
ShopStatusRepository $statusRepo,
|
||||
TransportRepository $transportRepo,
|
||||
PaymentMethodRepository $paymentRepo
|
||||
) {
|
||||
$this->statusRepo = $statusRepo;
|
||||
$this->transportRepo = $transportRepo;
|
||||
$this->paymentRepo = $paymentRepo;
|
||||
}
|
||||
|
||||
public function statuses(): void
|
||||
{
|
||||
if (!ApiRouter::requireMethod('GET')) {
|
||||
return;
|
||||
}
|
||||
|
||||
$statuses = $this->statusRepo->allStatuses();
|
||||
|
||||
$result = [];
|
||||
foreach ($statuses as $id => $name) {
|
||||
$result[] = [
|
||||
'id' => (int)$id,
|
||||
'name' => (string)$name,
|
||||
];
|
||||
}
|
||||
|
||||
ApiRouter::sendSuccess($result);
|
||||
}
|
||||
|
||||
public function transports(): void
|
||||
{
|
||||
if (!ApiRouter::requireMethod('GET')) {
|
||||
return;
|
||||
}
|
||||
|
||||
$transports = $this->transportRepo->allActive();
|
||||
|
||||
$result = [];
|
||||
foreach ($transports as $transport) {
|
||||
$result[] = [
|
||||
'id' => (int)($transport['id'] ?? 0),
|
||||
'name' => (string)($transport['name_visible'] ?? $transport['name'] ?? ''),
|
||||
'cost' => (float)($transport['cost'] ?? 0),
|
||||
];
|
||||
}
|
||||
|
||||
ApiRouter::sendSuccess($result);
|
||||
}
|
||||
|
||||
public function payment_methods(): void
|
||||
{
|
||||
if (!ApiRouter::requireMethod('GET')) {
|
||||
return;
|
||||
}
|
||||
|
||||
$methods = $this->paymentRepo->allActive();
|
||||
|
||||
$result = [];
|
||||
foreach ($methods as $method) {
|
||||
$result[] = [
|
||||
'id' => (int)($method['id'] ?? 0),
|
||||
'name' => (string)($method['name'] ?? ''),
|
||||
];
|
||||
}
|
||||
|
||||
ApiRouter::sendSuccess($result);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user