Skip to content

LinkField Link/SiteTreeLink records have no content-api write surface at all #116

Description

@jsirish

Context

Same source as #115 — mining a client production-restructure project's Epic A retrospective. LinkField
records were the second-most common reason a BuildTask was needed instead of content-api.

The gap

SilverStripe\LinkField\Models\Link and its subclasses (SiteTreeLink, EmailLink,
ExternalLink, etc.) have zero content-api surface — not even a read path via the schema/records
endpoints, as far as this project's exploration found. Every nav link, footer link, CTA card
link, or hero-slide button link needs a BuildTask:

// Temp05NavTask.php — utility nav / footer nav
$link = SiteTreeLink::create();
$link->LinkText = $add['title'];
$link->PageID = $page->ID;
$link->OwnerID = $aboutGroup->ID;
$link->OwnerClass = NavigationGroup::class;
$link->OwnerRelation = 'NavigationLinks';
$link->write();

This compounds with #115 (Elemental content) — most LinkField records on a typical Elemental
site are owned by an Element (a CTA card's link, a hero slide's link), so fixing #115 alone
still leaves the link itself unreachable.

Ask

Expose Link/SiteTreeLink to api_writable_fields/api_writable_relations the same way any
polymorphic-owner DataObject is exposed. The OwnerID/OwnerClass/OwnerRelation polymorphic
pattern is presumably the main design question — worth scoping whether a generic polymorphic-owner
write path is a bigger ask than this issue alone, or whether Link can just declare
content_api_access like any other class and be written via OwnerID/OwnerClass as plain
writable fields, same as any other has_one FK.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions