Problem/Motivation
The module currently exposes the Content First tab on every node and every menu with no way to restrict it. Sites with many content types often want the feature active only for specific ones — for example, only for article and landing_page, not for internal helper types.
There is no configuration to control which entity types or bundles participate in Content First, and the Drush export command has no awareness of any such restrictions.
Proposed resolution
Add a new Enabled entities and bundles section to the Content First configuration form at /admin/config/content/content-first.
The rules are:
- If an entity type (node or menu) is unchecked, the Content First tab is hidden for all its bundles and the Drush export skips it by default.
- If an entity type is checked but no bundles are selected, all bundles are permitted (existing behaviour).
- If one or more bundles are selected, only those bundles are permitted.
The restriction is enforced in two places:
- Routing: a new
ContentFirstEntityAccessCheckservice is registered as anaccess_checkand applied via the_content_first_entity_accessrequirement on the node and menu routes. It readscontent_first.settingsand returnsAccessResult::forbidden()when the entity type is disabled or the bundle is not in the allowed list, andAccessResult::allowed()otherwise. Results are cached onconfig:content_first.settings. - Drush export: when
content-first:exportis run without explicit--entityor--bundlesoptions, the command now reads the saved configuration to determine which entity types and bundles to export. Explicit CLI flags always override configuration.
Both node and menu are enabled with no bundle restrictions in the default configuration, preserving existing behaviour on fresh installs. A hook_update writes the same defaults for existing sites.
The implementation is structured to make adding future entity types straightforward: register the route with _content_first_entity_access: 'TRUE', add a parameter block to the access checker, and add a field group to the config form.
Remaining tasks
- Review and commit the patch.
User interface changes
A new Enabled entities and bundles fieldset is added at the top of the Content First configuration form. It contains:
- A Nodes checkbox. When checked, a secondary Allowed content types checklist appears (one entry per content type). Leave all unchecked to allow all types.
- A Menus checkbox. When checked, an Allowed menus checklist appears (one entry per menu). Leave all unchecked to allow all menus.
API changes
New service: content_first.entity_access_check (ContentFirstEntityAccessCheck), tagged as access_check with applies_to: _content_first_entity_access.
The ContentFirstCommands constructor gains a new required argument: ConfigFactoryInterface $configFactory.
Data model changes
A new entities key is added to content_first.settings:
entities: node: enabled: true bundles: [] menu: enabled: true bundles: [] Existing sites receive these defaults via content_first_update_20004().
Issue fork content_first-3589821
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #3
gedur commented