YamlFormPluginExporterController.php in YAML Form 8
File
src/Controller/YamlFormPluginExporterController.php
View source
<?php
namespace Drupal\yamlform\Controller;
use Drupal\Core\Controller\ControllerBase;
use Drupal\Component\Plugin\PluginManagerInterface;
use Drupal\Core\DependencyInjection\ContainerInjectionInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
class YamlFormPluginExporterController extends ControllerBase implements ContainerInjectionInterface {
protected $pluginManager;
public function __construct(PluginManagerInterface $plugin_manager) {
$this->pluginManager = $plugin_manager;
}
public static function create(ContainerInterface $container) {
return new static($container
->get('plugin.manager.yamlform.exporter'));
}
public function index() {
$definitions = $this->pluginManager
->getDefinitions();
$definitions = $this->pluginManager
->getSortedDefinitions($definitions);
$rows = [];
foreach ($definitions as $plugin_id => $definition) {
$rows[$plugin_id] = [
$plugin_id,
$definition['label'],
$definition['description'],
$definition['provider'],
];
}
ksort($rows);
return [
'#type' => 'table',
'#header' => [
$this
->t('ID'),
$this
->t('Label'),
$this
->t('Description'),
$this
->t('Provided by'),
],
'#rows' => $rows,
'#sticky' => TRUE,
];
}
}