Explicit Allow Only
#[Silverback\ExplicitAllowOnly] marks a component type as opt-in. By default a component group with no allowedComponents restriction accepts every type; a type flagged with this attribute is the exception — it may only be placed in a group whose allowedComponents explicitly lists it. Everywhere else it is hidden from the admin and rejected on save.
Use it for components that should never appear by accident — structural or layout-only pieces (a section divider, a grid cell, a slot that only makes sense inside one specific parent).
Setup
Add the attribute to the component entity. No trait or extra properties are required:
use Silverback\ApiComponentsBundle\Annotation as Silverback;
use Silverback\ApiComponentsBundle\Entity\Core\AbstractComponent;
#[Silverback\ExplicitAllowOnly]
#[ORM\Entity]
#[ApiResource]
class SectionDivider extends AbstractComponent
{
// ...
}
How It's Enforced
Once a type is flagged, it becomes opt-in in every placement path:
- Hidden in the admin — it does not appear in the "Add Component" dialog for any group that doesn't list it.
- Rejected on save — a
ComponentPositionpointing at it, in a group that doesn't allow it, fails validation. This applies to both directly placed components and dynamic page-data positions, so the dynamic path can't be used to bypass the rule.
Allowing the Type in a Group
To use the component, add its collection IRI to the target group's allowedComponents. A group whose allowedComponents is null still allows all non-flagged types — but a flagged type must always be named explicitly.
// Fixtures — list the flagged type in the group's allow list
$cwa->layout('primary', 'PrimaryLayout')
->group('structure', [App\Entity\SectionDivider::class]);
See <CwaComponentGroup> → Allowed Components for the Vue-prop, REST, and fixture ways to set allowedComponents.
The Hydra Flag
The attribute is surfaced to clients as a bare explicitAllowOnly: true boolean on the component's supportedClass entry in the Hydra API documentation. This is how the admin UI knows to treat the type as opt-in without any extra configuration.
{
"@type": "hydra:Class",
"hydra:title": "SectionDivider",
"explicitAllowOnly": true
}