Created
December 27, 2022 23:03
-
-
Save mentisy/8b2b9bc4004bad504f83a5d839b1e560 to your computer and use it in GitHub Desktop.
Plugins panel for CakePHP's plugin DebugKit
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// bootstrap in Application.php | |
Configure::write('DebugKit.panels', ['plugins']); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* @var \Cake\View\View $this | |
* @var array $plugins | |
* @var int $pluginsCount | |
*/ | |
?> | |
<table class=""> | |
<thead> | |
<tr> | |
<th>Plugin</th> | |
<th>Path</th> | |
</tr> | |
</thead> | |
<tbody> | |
<?php foreach ($plugins as $plugin): ?> | |
<tr> | |
<td><?= $plugin['name'] ?></td> | |
<td><?= $plugin['path'] ?></td> | |
</tr> | |
<?php endforeach ?> | |
</tbody> | |
</table> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
declare(strict_types=1); | |
namespace App\Panel; | |
use Cake\Core\Plugin; | |
use Cake\Event\EventInterface; | |
use DebugKit\DebugPanel; | |
class PluginsPanel extends DebugPanel | |
{ | |
/** | |
* Data collection callback. | |
* | |
* @param \Cake\Event\EventInterface $event The shutdown event. | |
* @return void | |
*/ | |
public function shutdown(EventInterface $event): void | |
{ | |
$pluginsCollection = Plugin::getCollection(); | |
$plugins = []; | |
foreach ($pluginsCollection as $plugin) { | |
$plugins[] = [ | |
'name' => $plugin->getName(), | |
'path' => $plugin->getPath(), | |
]; | |
} | |
$this->_data = compact('plugins'); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment