0

i have a variable_set defined in d6 as follows :

variable_set('cleanupeditform_formkeys', array(
 'menu' => t('Menu settings'),
 'revision_information' => t('Revision information'),
 'attachments' => t('File attachments'),
 'comment_settings' => t('Comment settings'),
 'author' => t('Authoring information'),
 'options' => t('Publishing options'),
 ));

How i can convert to drupal 8 form ? I know for a single case it would be like

\Drupal::state()->set('cleanupeditform_formkeys','my_value');

Thanks .

1

It's no different, you can also save an array in state:

\Drupal::state()->set('cleanupeditform_formkeys', ['foo' => 'bar']);
1

You should use \Drupal::config() instead of \Drupal::state(). States are used for hidden system values and are not deployed between environments, but configs store values/changes from site building process and could be synchronized between environments.

  • The OP didn't really leave any clues as to whether this data belongs in config or state (except for using state in the question), so I don't you think can say that config "should" be used here - you need more context to be able to say that for sure. But the point that there are different stores is a good one to raise – Clive Apr 26 '16 at 11:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.