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 ContentFirstEntityAccessCheck service is registered as an access_check and applied via the _content_first_entity_access requirement on the node and menu routes. It reads content_first.settings and returns AccessResult::forbidden() when the entity type is disabled or the bundle is not in the allowed list, and AccessResult::allowed() otherwise. Results are cached on config:content_first.settings.
  • Drush export: when content-first:export is run without explicit --entity or --bundles options, 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().

Command icon 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

gedur created an issue. See original summary.

gedur’s picture

Status: Active » Fixed

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

  • gedur committed f6dbbdc6 on 2.x
    Issue #3589821: Admin config to enable/disable entities and restrict by...

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.