Repository navigation
Drupal permission and configuration names - #540
Conversation
|
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
Permission names complete, go to the permissions file that declares them, and show their title and description on hover, wherever a site reads one: access checks on accounts and roles, the access result helpers, the user module's role functions, a route's `_permission` requirement, and an entity type's `admin_permission`. Assisted-by: claude-code/claude-opus-5-5
Configuration names complete and go to the default configuration that ships them and the schema entry that describes them, wherever a site reads one: `\Drupal::config()`, the config factory, the `config()` shortcut of controllers and forms, a config form's editable names, and a form element's `#config_target`. Assisted-by: claude-code/claude-opus-5-5
A chained call whose return type is a union of generic types keeps each member's type arguments on its class, as a single generic return type already does. An entity type ID two classes declare with their own storage now loads either entity when the load is chained straight on `getStorage()`. Assisted-by: claude-code/claude-opus-5-5
A configuration object read by its name carries the name in its type, and its `get()`, `set()` and `clear()` complete the keys its schema declares, one level at a time, and go to their schema line. `set()` and `clear()` offer keys only on an editable object. The key after the `:` of a `#config_target` and a `ConfigTarget`'s property path do the same. Assisted-by: claude-code/claude-opus-5-5
Assisted-by: claude-code/claude-opus-5-5
Assisted-by: claude-code/claude-opus-5-5
Drupal rejects a configuration name that has no `.`, so a call whose
literal argument has none cannot read a configuration object. Checking
that first spares the config factory and trait subtype walks on the
far more common entity `->get('field_name')` calls.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Thanks. You might want to take a look at this:
|
Thanks, good catch. #543 keeps each schema file as it was last read and reads only the edited file again, then rebuilds the index in memory. Opening, saving or closing a schema file without changes costs nothing. |
Adds DR8: Drupal permission names and configuration names complete, go to their declaration and show details, and a configuration object's keys complete from its schema.
*.permissions.ymlcomplete, go to their declaration, and show their title and description on hover. This works in access checks (hasPermission(),AccessResult::allowedIfHasPermission(s)(), role grants), in each part of a route's_permission(a+b,a,b), and in an entity type'sadmin_permission.config/install,config/optional) and from the schema complete, and go to both the shipped file and the schema entry. This works in\Drupal::config(), the config factory,config()in controllers and forms,getEditableConfigNames(), and#config_target.get()completes the keys the schema declares, one level at a time, and goes to their schema line.set()andclear()do the same on an editable object only. Keys follow the object through variables and chains, because the configuration name travels in its type (ImmutableConfig<'acme.settings'>, shown on hover).config()returnsConfig|ImmutableConfigand needs this, and a chainedload()on an entity type ID declared twice now resolves too.Permissions built by permission callbacks (
create article content) are not read. They are filed as DR22, and a warning for unknown permission names as DR23, which depends on DR22.How to test: run
composer installinexamples/drupal, then openexamples/drupalwith this branch's build. Inweb/modules/custom/acme/:src/NoteAccess.php: hover'administer acme'to see its title and description. Empty the string and complete: acme's and core's permissions are offered.acme.routing.yml: go to the definition of either half of'view acme notes+administer acme'.src/Form/SettingsForm.php: go to the definition of'acme.settings'to reachconfig/install/acme.settings.ymlandconfig/schema/acme.schema.yml. Emptyget('notifications.email')and complete to getnotify_emailandnotifications. Typenotifications.to getemail.Checklist
If applicable:
CHANGELOG.mdREADME.md,docs/,examples/)config-schema.json). Not applicable: this PR adds or changes no setting.the changes and why they are needed.
the changelog, and other user-facing content, and removed or corrected
anything inaccurate, unclear, or unnecessary.