Skip to content

Instantly share code, notes, and snippets.

@mentisy
Created December 27, 2022 23:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mentisy/8b2b9bc4004bad504f83a5d839b1e560 to your computer and use it in GitHub Desktop.
Save mentisy/8b2b9bc4004bad504f83a5d839b1e560 to your computer and use it in GitHub Desktop.
Plugins panel for CakePHP's plugin DebugKit
<?php
// bootstrap in Application.php
Configure::write('DebugKit.panels', ['plugins']);
<?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>
<?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