File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 77 $ routes ->setExtensions ('json ' );
88 $ routes ->setRouteClass (DashedRoute::class);
99
10- $ routes ->connect ('/ ' , ['controller ' => 'DebugKit ' , 'action ' => 'index ' ]);
1110
1211 $ routes ->connect (
1312 '/toolbar/clear-cache ' ,
@@ -42,5 +41,7 @@ function (RouteBuilder $routes) {
4241 }
4342 );
4443
45- $ routes ->fallbacks ();
44+ $ routes ->get ('/ ' , ['controller ' => 'DebugKit ' , 'action ' => 'index ' ]);
45+ $ routes ->get ('/dashboard ' , ['controller ' => 'DebugKit ' , 'action ' => 'index ' ]);
46+ $ routes ->post ('/dashboard/reset ' , ['controller ' => 'DebugKit ' , 'action ' => 'reset ' ]);
4647});
Original file line number Diff line number Diff line change @@ -49,32 +49,28 @@ public function beforeFilter(Event $event)
4949 */
5050 public function index ()
5151 {
52- $ connection = ConnectionManager:: getConfig ( ' debug_kit ' );
52+ $ this -> loadModel ( ' DebugKit.Requests ' );
5353
54- if ($ connection ['driver ' ] === Sqlite::class) {
55- $ connection ['location ' ] = str_replace (ROOT . DS , DS , $ connection ['database ' ]);
56- $ connection ['size ' ] = 0 ;
57- if (file_exists ($ connection ['database ' ])) {
58- $ connection ['size ' ] = filesize ($ connection ['database ' ]);
59- }
60- }
54+ $ data = [
55+ 'driver ' => get_class ($ this ->Requests ->getConnection ()->getDriver ()),
56+ 'rows ' => $ this ->Requests ->find ()->count (),
57+ ];
6158
62- $ this ->set (compact ( 'connection ' ) );
59+ $ this ->set ('connection ' , $ data );
6360 }
6461
6562 /**
6663 * Reset SQLite DB.
6764 *
68- * @return \Cake\Http\Response|null
65+ * @return \Cake\Http\Response
6966 */
7067 public function reset ()
7168 {
7269 $ this ->request ->allowMethod ('post ' );
70+ $ this ->loadModel ('DebugKit.Requests ' );
7371
74- $ connection = ConnectionManager::getConfig ('debug_kit ' );
75- if ($ connection ['driver ' ] === Sqlite::class && file_exists ($ connection ['database ' ])) {
76- unlink ($ connection ['database ' ]);
77- }
72+ $ this ->Requests ->Panels ->deleteAll ('1=1 ' );
73+ $ this ->Requests ->deleteAll ('1=1 ' );
7874
7975 return $ this ->redirect (['action ' => 'index ' ]);
8076 }
Original file line number Diff line number Diff line change 33 * @var \App\View\AppView $this
44 */
55?>
6- <h1>Debug Kit</h1>
6+ <h1><?= __d ( ' debug_kit ' , ' Debug Kit Dashboard ' ) ?> </h1>
77
8- <h2>Database</h2>
8+ <h2><?= __d ( ' debug_kit ' , ' Database ' ) ?> </h2>
99<ul>
10- <li><?= h ($ connection ['driver ' ]); ?> </li>
11- <?php if (isset ($ connection ['size ' ])): ?>
12- <li>DB Size : <?php echo $ this ->Number ->toReadableSize ($ connection ['size ' ]); ?> </li>
10+ <li><?= __d ( ' debug_kit ' , ' Driver ' ) ?> : <?= h ($ connection ['driver ' ]); ?> </li>
11+ <?php if (isset ($ connection ['rows ' ])): ?>
12+ <li><?= __d ( ' debug_kit ' , ' Requests ' ) ?> : <?= $ this ->Number ->format ($ connection ['rows ' ]) ?> </li>
1313 <?php endif ; ?>
1414</ul>
15- <?php if (!empty ($ connection ['size ' ])): ?>
16- <?php echo $ this ->Form ->postLink ('Reset ' , ['action ' => 'reset ' ], ['confirm ' => 'Sure? ' ]); ?>
15+ <?php if (!empty ($ connection ['rows ' ])): ?>
16+ <?= $ this ->Form ->postLink (
17+ __d ('debug_kit ' , 'Reset database ' ),
18+ ['_method ' => 'POST ' , 'action ' => 'reset ' ],
19+ ['confirm ' => 'Are you sure? ' ]
20+ ); ?>
1721<?php endif ; ?>
1822
1923<h3>Actions</h3>
2024<ul>
21- <li><?php echo $ this ->Html ->link (' Mail Preview ' , ['controller ' => 'MailPreview ' ]); ?> </li>
25+ <li><?= $ this ->Html ->link (__d ( ' debug_kit ' , ' Mail Preview ') , ['controller ' => 'MailPreview ' ]); ?> </li>
2226</ul>
You can’t perform that action at this time.
0 commit comments