AbstractOptionalModule.php in Thunder 8.2
File
src/Plugin/Thunder/OptionalModule/AbstractOptionalModule.php
View source
<?php
namespace Drupal\thunder\Plugin\Thunder\OptionalModule;
use Drupal\Core\Config\ConfigFactoryInterface;
use Drupal\Core\Entity\EntityTypeManagerInterface;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
use Drupal\Core\Plugin\PluginBase;
use Symfony\Component\DependencyInjection\ContainerInterface;
abstract class AbstractOptionalModule extends PluginBase implements ContainerFactoryPluginInterface {
protected $entityTypeManager;
protected $configFactory;
public function __construct(array $configuration, $plugin_id, $plugin_definition, EntityTypeManagerInterface $entityTypeManager, ConfigFactoryInterface $configFactory) {
parent::__construct($configuration, $plugin_id, $plugin_definition);
$this->entityTypeManager = $entityTypeManager;
$this->configFactory = $configFactory;
}
public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) {
return new static($configuration, $plugin_id, $plugin_definition, $container
->get('entity_type.manager'), $container
->get('config.factory'));
}
public function buildForm(array $form, FormStateInterface $form_state) {
$reflection = new \ReflectionClass($this);
foreach ($reflection
->getMethods() as $method) {
if ($method->name == 'buildForm') {
if ($method->class != get_class($this)) {
return $form;
}
}
}
$form[$this
->getBaseId()] = [
'#type' => 'details',
'#title' => $this->pluginDefinition['label'],
'#open' => TRUE,
'#states' => [
'visible' => [
':input[name="install_modules_' . $this
->getBaseId() . '"]' => [
'checked' => TRUE,
],
],
],
];
return $form;
}
public function submitForm(array $formValues) {
}
}