Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Leverage the plugin form interface instead of a custom settingsForm method #5

Open
wants to merge 1 commit into
base: 8.x-1.x
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions src/Plugin/AutoValue/RandomValue.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
use Drupal\autovalue\Plugin\AutoValueInterface;
use Drupal\autovalue\Plugin\ConfigurableAutoValueBase;
use Drupal\Component\Utility\Random;
use Drupal\Core\Form\FormStateInterface;

/**
* Defines an random value generator.
Expand Down Expand Up @@ -82,8 +83,8 @@ public function resetValue() {
/**
* {@inheritdoc}
*/
public function getSettingsForm(array $form, array &$form_state) {
return parent::getSettingsForm($form, $form_state) + [
public function buildConfigurationForm(array $form, FormStateInterface $form_state) {
return parent::buildConfigurationForm($form, $form_state) + [
'value_type' => [
'#type' => 'select',
'#title' => $this->t('Type of value.'),
Expand Down
6 changes: 3 additions & 3 deletions src/Plugin/AutoValue/TokenPattern.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
use Drupal\autovalue\Plugin\AutoValueInterface;
use Drupal\autovalue\Plugin\ConfigurableAutoValueBase;
use Drupal\Component\Utility\NestedArray;
use Drupal\Core\Form\FormStateInterface;

/**
* Defines an automatic value plugin which is based on text patterns with
Expand Down Expand Up @@ -58,9 +59,8 @@ public function getValue() {
/**
* {@inheritdoc}
*/
public function getSettingsForm(array $form, array &$form_state) {

return parent::getSettingsForm($form, $form_state) + [
public function buildConfigurationForm(array $form, FormStateInterface $form_state) {
return parent::buildConfigurationForm($form, $form_state) + [
'pattern' => [
'#type' => 'textarea',
'#title' => $this->t('Token Pattern'),
Expand Down
19 changes: 16 additions & 3 deletions src/Plugin/ConfigurableAutoValueBase.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,31 @@

use Drupal\Component\Plugin\ConfigurablePluginInterface;
use Drupal\Component\Utility\NestedArray;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Plugin\PluginDependencyTrait;
use Drupal\Core\Plugin\PluginFormInterface;

abstract class ConfigurableAutoValueBase extends AutoValueBase implements ConfigurablePluginInterface {
abstract class ConfigurableAutoValueBase extends AutoValueBase implements ConfigurablePluginInterface, PluginFormInterface {

/**
* {@inheritdoc}
*/
public function getSettingsForm(array $form, array &$form_state) {

public function buildConfigurationForm(array $form, FormStateInterface $form_state) {
return [];
}

/**
* {@inheritdoc}
*/
public function validateConfigurationForm(array &$form, FormStateInterface $form_state) {
}

/**
* {@inheritdoc}
*/
public function submitConfigurationForm(array &$form, FormStateInterface $form_state) {
}

/**
* {@inheritdoc}
*/
Expand Down