AssignmentCoreForm.php in Features 8.3
File
modules/features_ui/src/Form/AssignmentCoreForm.php
View source
<?php
namespace Drupal\features_ui\Form;
use Drupal\Core\Form\FormStateInterface;
class AssignmentCoreForm extends AssignmentFormBase {
const METHOD_ID = 'core';
public function getFormId() {
return 'features_assignment_core_form';
}
public function buildForm(array $form, FormStateInterface $form_state, $bundle_name = NULL) {
$this->currentBundle = $this->assigner
->loadBundle($bundle_name);
$settings = $this->currentBundle
->getAssignmentSettings(self::METHOD_ID);
$this
->setConfigTypeSelect($form, $settings['types']['config'], $this
->t('core'));
$this
->setActions($form, self::METHOD_ID);
return $form;
}
public function validateForm(array &$form, FormStateInterface $form_state) {
$form_state
->setValue('types', array_map('array_filter', $form_state
->getValue('types')));
}
public function submitForm(array &$form, FormStateInterface $form_state) {
$settings = $this->currentBundle
->getAssignmentSettings(self::METHOD_ID);
$settings['types'] = $form_state
->getValue('types');
$this->currentBundle
->setAssignmentSettings(self::METHOD_ID, $settings)
->save();
$this
->setRedirect($form_state);
$this
->messenger()
->addStatus($this
->t('Package assignment configuration saved.'));
}
}