protected function setUp() { parent::setUp(); $this->service = new NotificationService($this->backend, false); // Register some notification types $formatterRegistry = $this->service->getFormatterRegistry(); $formatterRegistry->registerType('friend:something', '\\MakinaCorpus\\APubSub\\Notification\\Formatter\\RawFormatter'); $formatterRegistry->registerType('friend:friended', '\\MakinaCorpus\\APubSub\\Notification\\Formatter\\RawFormatter'); $formatterRegistry->registerType('content'); $formatterRegistry->registerType('disabled'); }
/** * {inheritdoc} */ public function buildForm(array $form, FormStateInterface $form_state) { $registry = $this->service->getFormatterRegistry(); $typeList = $registry->getTypeList(); $label_disabled = $this->t("Disabled"); $label_enabled = '<strong>' . $this->t("Enabled") . '</strong>'; $options = []; foreach ($typeList as $type) { try { $options[$type]['type'] = $type; $options[$type]['status'] = $label_enabled; $options[$type]['status'] = true ? $label_enabled : $label_disabled; // FIXME } catch (Exception $e) { // @todo ? } } $form['types'] = ['#type' => 'tableselect', '#header' => ['type' => $this->t("Type"), 'status' => $this->t("Status")], '#options' => $options]; $form['actions'] = ['#type' => 'actions']; $form['actions']['enable'] = ['#type' => 'submit', '#value' => $this->t("Enable"), '#submit' => ['::enableSubmit']]; $form['actions']['disable'] = ['#type' => 'submit', '#value' => $this->t("Disable"), '#submit' => ['::disableSubmit']]; return $form; }