Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 19 |
|
0.00% |
0 / 2 |
CRAP | |
0.00% |
0 / 1 |
| StyleGuidePageController | |
0.00% |
0 / 19 |
|
0.00% |
0 / 2 |
30 | |
0.00% |
0 / 1 |
| checkAdminPermission | |
0.00% |
0 / 8 |
|
0.00% |
0 / 1 |
12 | |||
| index | |
0.00% |
0 / 11 |
|
0.00% |
0 / 1 |
6 | |||
| 1 | <?php |
| 2 | /** |
| 3 | * StyleGuidePageController |
| 4 | * |
| 5 | * Handles rendering of the Style Guide Reference Page. |
| 6 | * This is a developer tool that displays all design system components |
| 7 | * with live examples and copyable code snippets. |
| 8 | */ |
| 9 | |
| 10 | namespace BuyerKiosk\StyleGuide\Controllers; |
| 11 | |
| 12 | use BuyerKiosk\Core\Controllers\BaseController; |
| 13 | |
| 14 | class StyleGuidePageController extends BaseController |
| 15 | { |
| 16 | /** |
| 17 | * Check admin permission and redirect if not authorized |
| 18 | * |
| 19 | * @return bool True if authorized |
| 20 | */ |
| 21 | private function checkAdminPermission() |
| 22 | { |
| 23 | $app = $this->_app; |
| 24 | |
| 25 | // Check user is logged in |
| 26 | if (!$app->user) { |
| 27 | $app->redirect($app->urlFor('login')); |
| 28 | return false; |
| 29 | } |
| 30 | |
| 31 | // Check user has admin permission |
| 32 | // Style guide is for developers/admins only |
| 33 | if (!$app->user->checkAccess('uri_store_settings')) { |
| 34 | $app->notAuthorized(); |
| 35 | return false; |
| 36 | } |
| 37 | |
| 38 | return true; |
| 39 | } |
| 40 | |
| 41 | /** |
| 42 | * Render the Style Guide Reference Page |
| 43 | * |
| 44 | * GET /admin/style-guide |
| 45 | * |
| 46 | * Displays all design system components organized by category: |
| 47 | * Colors, Typography, Spacing, Buttons, Badges, Stat Cards, |
| 48 | * Event Cards, Item Cards, Forms, Tables, Modals, Tabs, |
| 49 | * Icons, Masonry, Migration Guide |
| 50 | */ |
| 51 | public function index() |
| 52 | { |
| 53 | if (!$this->checkAdminPermission()) { |
| 54 | return; |
| 55 | } |
| 56 | |
| 57 | $app = $this->_app; |
| 58 | |
| 59 | // Render the style guide template |
| 60 | $app->render('admin/style-guide.html', [ |
| 61 | 'page' => [ |
| 62 | 'title' => 'Style Guide Reference', |
| 63 | 'description' => 'BuyerKiosk Design System - Live component reference for developers' |
| 64 | ], |
| 65 | 'user' => $app->user, |
| 66 | 'csrf_token' => \NoCSRF::generate('csrf_token') |
| 67 | ]); |
| 68 | } |
| 69 | } |