Quantcast
Channel: Issues for Drupal core
Viewing all articles
Browse latest Browse all 292847

Determine which core config entity methods should be config actions

$
0
0

Problem/Motivation

In #3284025: Add configuration actions API we added the ability to add an attribute to config entity methods to make them available to the config actions APIs and, thereby, recipes. We added the attribute to \Drupal\user\Entity\Role::grantPermission() like so:

  /**
   * {@inheritdoc}
   */
  #[ActionMethod(adminLabel: new TranslatableMarkup('Add permission to role'))]
  public function grantPermission($permission) {

The question is what other core provided config entity methods should be available to actions?

Proposed resolution

  1. Determine the methods to make into actions
  2. Make it so

Here are the actions this MR adds, with examples for documentation:

set: Changes a property of a config entity. This is a pretty low-level method and should generally only be used if no dedicated method exists. Works on all config entities.

user.role.authenticated:
  set:
    property_name: label
    value: Logged-in user

setMultiple: Same as set, but accepts multiple property/value pairs.

user.role.authenticated:
  setMultiple:
    - property_name: label
      value: Logged-in user
    - property_name: is_admin
      value: false

enable: Marks any config entity as "enabled". The effect of this varies by the config entity type. Works on all config entities.

views.view.files:
  enable: []

disable: Marks any config entity as "disabled". THe effect of this varies by config entity type. For example, disabling a view keeps it editable in the administrative UI, but makes it unavailable everywhere else. Works on all config entities.

views.view.files:
  disable: []

hideComponent: Hides a component from an entity view display or entity form display.

core.entity_view_display.node.page.full:
  hideComponent: uid

hideComponents: Same as hideComponent, but hides more than one component.

core.entity_form_display.media.image.default:
  hideComponents:
    - uid
    - path

setLabel: Changes the human-readable label of a field. Works on fields and base field overrides.

field.field.node.page.field_byline:
  setLabel: 'Byline for this page'

setDescription: Changes the user-facing description of a field. Works on fields and base field overrides.

field.field.node.page.field_byline:
  setDescription: 'Enter the name or credit of whoever created this magnificent page.'

setTranslatable: Sets whether a field should be translatable in the UI, or not. Works on fields and base field overrides. (Note that most fields are translatable by default.)

field.field.node.page.field_byline:
  setTranslatable: true

setSettings: Changes field settings. Exactly which settings are available, and what they mean, varies by the field type. Any preexisting settings are added automatically, with the incoming settings taking precedence. Works on fields and base field overrides.

field.field.node.page.field_byline:
  setSettings:
    display_summary: true
    required_summary: true

setRequired: Sets whether users must enter a value for a field. Works on fields and base field overrides.

field.field.node.page.field_byline:
  setRequired: true

setDefaultValue: Sets the default value of a field, which can be changed by users when editing content. Exactly what the default value should look like, varies by field type. Works on fields and base field overrides.

field.field.node.page.field_byline:
  setDefaultValue:
    value: "Joe Bag o'Donuts"

setRegion: Sets the region in which a block should be. Which regions are available depends on which theme the block is in. Only works on blocks.

block.block.olivero_powered:
  setRegion: page_bottom

setWeight: Sets the weight (position relative to other blocks in the same region of the same theme) of a block. Accepts any number. Only works on blocks.

block.block.olivero_powered:
  setWeight: 39

setMessage: Sets the message that a contact form should display to users when they submit the form. Only works on contact forms.

contact.form.feedback:
  setMessage: 'Thanks for telling us how you feel.'

setRecipients: Sets the email addresses that should be notified when a user submits a contact form. Accepts an array of email addresses. Only works on contact forms.

contact.form.feedback:
  setRecipients:
    - king@monarchy.uk
    - chief@example.com

setRedirectPath: Sets the path (URL) where users should be redirected when they submit a contact form. Must start with a slash. Only works on contact forms.

contact.form.feedback:
  setRedirectPath: '/thank-you'

setReply: Sets a message to be emailed to the person who submitted a contact form. Only works on contact forms.

contact.form.feedback:
  setReply: 'We have received your feedback and will get back to you at some point when the planets align properly.'

setWeight: Sets the weight of the contact form, relative to other contact forms, in the administrative UI. Accepts a number. Only works on contact forms.

contact.form.feedback:
  setWeight: -50

User interface changes

API changes

Data model changes


Viewing all articles
Browse latest Browse all 292847

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>