Conversation
Adds Link and LinkProvider classes implementing PSR-13 EvolvableLinkInterface and EvolvableLinkProviderInterface. - Link: represents a hypermedia link (RFC 5988/8288) - LinkProvider: collects and provides links - Full test coverage
array<string>|string instead of string|array<string>
|
So far this itself is not useful yet. |
- Update @SInCE from 5.2.0 to 5.4.0 in Link classes and tests - Add psr/link dependency to src/Http/composer.json - Add psr/link-implementation to provides - Add PSR-13 to description and keywords
|
I am stupid, this is about HTTP Header Links, not HTML links 🤦🏻 |
Integration PointsJust some ideas: 1. Response IntegrationAdd methods to // In Response or via a trait
public function withLink(LinkInterface $link): static
public function getLinks(): LinkProviderInterface2. LinkHeaderMiddlewareAutomatically converts links to HTTP // Response with links gets header:
// Link: </css/app.css>; rel="preload"; as="style"3. View HelperFor outputting // In template
echo $this->Html->linkTag($this->response->getLinks());4. Pagination IntegrationAuto-add Implementation Options
|
|
I think for us to provide PSR-13 support we'd need to also include some of the integration points that @dereuromark outlined. Without those I don't see the point. |
- Add withLink(), withoutLink(), getLinks(), withLinkProvider() to Response - Add LinkHeaderMiddleware to convert PSR-13 links to HTTP Link headers - Add tests for Response link methods and LinkHeaderMiddleware
Per review feedback, Link headers are now emitted by ResponseEmitter (similar to cookie handling) instead of requiring a separate middleware. Removed LinkHeaderMiddleware and added tests to ResponseEmitterTest.
LordSimal
left a comment
There was a problem hiding this comment.
I wouldn't have needed this till now but maybe someone will eventually.
Summary
Adds PSR-13
LinkInterfaceandLinkProviderInterfaceimplementations for hypermedia link support.Cake\Http\Link\LinkimplementsEvolvableLinkInterfaceCake\Http\Link\LinkProviderimplementsEvolvableLinkProviderInterfaceUsage
Changes
psr/linkto composer.json requirementspsr/link-implementationto composer.json providessrc/Http/Link/tests/TestCase/Http/Link/Refs: PSR-13 https://www.php-fig.org/psr/psr-13/