From cf042bd630d2052f5877b0d3102755e1dd685d6d Mon Sep 17 00:00:00 2001 From: DevSviat Date: Fri, 20 Nov 2026 12:35:46 +0200 Subject: [PATCH] =?UTF-8?q?fix:=20=D0=BA=D0=BD=D0=BE=D0=BF=D0=BA=D0=B0=20?= =?UTF-8?q?=C2=AB=D0=9D=D0=B0=D0=B7=D0=B0=D0=B4=C2=BB=20=D0=BD=D0=B0=20?= =?UTF-8?q?=D0=BA=D0=B0=D1=80=D1=82=D1=86=D1=96=20=D0=B0=D0=BA=D1=86=D1=96?= =?UTF-8?q?=D1=97=20=D0=B2=D0=B5=D0=B4=D0=B5=20=D0=BD=D0=B0=20=D1=81=D0=BF?= =?UTF-8?q?=D0=B8=D1=81=D0=BE=D0=BA=20=D0=B0=D0=BA=D1=86=D1=96=D0=B9=20(2.?= =?UTF-8?q?2.2)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Якщо картку відкрили без ?return=, посилання будувалося як {url controller=CampaignListAdmin}. Без вендора й модуля адмінка шукала такий контролер серед своїх, не знаходила і відкривала «Товари». Тепер посилання веде на Sviat.Promo.CampaignListAdmin. Тест перевіряє, що кожне {url controller=…} у шаблонах адмінки модуля вказує на наявний контролер. --- Backend/design/html/campaign_edit.tpl | 2 +- Init/module.json | 2 +- tests/BackendLinksControllerTest.php | 44 +++++++++++++++++++++++++++ 3 files changed, 46 insertions(+), 2 deletions(-) create mode 100644 tests/BackendLinksControllerTest.php diff --git a/Backend/design/html/campaign_edit.tpl b/Backend/design/html/campaign_edit.tpl index 0fc0b33..c3f1ad6 100644 --- a/Backend/design/html/campaign_edit.tpl +++ b/Backend/design/html/campaign_edit.tpl @@ -19,7 +19,7 @@ {$btr->general_open|escape} {/if} - + {include file='svg_icon.tpl' svgId='return'} {$btr->general_back|escape} diff --git a/Init/module.json b/Init/module.json index 3fba734..b49f80b 100644 --- a/Init/module.json +++ b/Init/module.json @@ -1,6 +1,6 @@ { "Okay": "4.5.3", - "version": "2.2.1", + "version": "2.2.2", "moduleName": "Promo: акції та знижки", "vendor": { "email": "devsviat@proton.me", diff --git a/tests/BackendLinksControllerTest.php b/tests/BackendLinksControllerTest.php new file mode 100644 index 0000000..64149c0 --- /dev/null +++ b/tests/BackendLinksControllerTest.php @@ -0,0 +1,44 @@ +getFileName(), 2) . '/design/html'; + $templates = glob($designDir . '/*.tpl') ?: []; + self::assertNotSame([], $templates); + + $unresolved = []; + foreach ($templates as $template) { + preg_match_all('/\{url\b[^}]*\bcontroller=([^\s}]+)/', (string) file_get_contents($template), $matches); + foreach ($matches[1] as $controller) { + if (!$this->resolves(trim($controller, '\'"'))) { + $unresolved[] = basename($template) . ': ' . $controller; + } + } + } + + self::assertSame([], $unresolved); + } + + private function resolves(string $controller): bool + { + if (preg_match('/^\[(\w+),\s*(\w+),\s*(\w+)\]$/', $controller, $parts) + || preg_match('/^(\w+)\.(\w+)\.(\w+)$/', $controller, $parts)) { + return class_exists("Okay\\Modules\\{$parts[1]}\\{$parts[2]}\\Backend\\Controllers\\{$parts[3]}"); + } + + return class_exists("Okay\\Admin\\Controllers\\{$controller}"); + } +}