Link Type API
Registered link classes define destination behaviour and provide settings and input controls. Start with Creating Link Types for a complete registration example. These methods are extension points for subclasses of verbb\hyper\base\Link.
Settings and Input Configuration
Static method returning the name shown to editors.
Return the settings Hyper should save for this link type. Start with the parent method’s values when adding your own settings.
Return the configuration and current values needed by the browser input.
Template variables including linkType.
Input context including link, layoutField and field.
Type-specific settings controls.
The destination input inside the Link layout field.
The following is a partial class example. Add these members to your custom link class when its settings template includes a hint input and its browser input needs that hint:
public ?string $hint = null;
public function getSettingsConfig(): array
{
$values = parent::getSettingsConfig();
$values['hint'] = $this->hint;
return $values;
}
public function getInputConfig(): array
{
$values = parent::getInputConfig();
$values['hint'] = $this->hint;
return $values;
}getSettingsConfig() makes the setting available for persistence with the definition. getInputConfig() does not replace that persistence or save arbitrary editor content. Store editor values in linkValue or custom layout fields; see Saved Content.
Destination Behaviour
Resolve the type-specific destination before prefix, suffix and URL-policy checks.
Resolve the type’s label, including appropriate defaults.
This is a static method, called as Link::isInstanceEmpty($instance).
Use this storage and authoring check to recognise entered destinations, labels, attributes or custom fields without requiring a resolvable URL. It is separate from a Link’s public isEmpty(), which checks its resolved destination. Preserve that separation when extending a link type so temporarily unavailable destinations do not discard authored content.
Static list of plugins needed for this type to be available.
Return true to allow editors to add several links of this type at once. This is a static method.
Return the bulk input mode, such as text or elements, when bulk creation is enabled. This is a static method.
Element types extend verbb\hyper\base\ElementLink and implement the static elementType(): string method. supportsUriSelectorCriteria(): bool controls whether URI-based selector settings apply. Keep getElement() nullable and respect the destination’s site and status.
The registry event is verbb\hyper\services\Links::EVENT_REGISTER_LINK_TYPES with a craft\events\RegisterComponentTypesEvent. Append your class to $event->types when registering it.