Download the PHP package rnr1721/le7-links without Composer
On this page you can find all versions of the php package rnr1721/le7-links. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package le7-links
le7-links
PSR LinkInterface implementation for le7 MVC framework or any PHP8 PSR project This is not "clean" implementation, this is combination of EnvolvedLinkInterface, UriInterface and own ULinkInterface.
Requirements
- PHP 8.1
- Composer
Installation
Testing
Usage
Link
The Link class represents a LinkInterface, UriInterface and own ULinkInterface with additional functionality for manipulating URIs and rendering HTML anchor tags.
First, import the Link class:
Create an instance of the Link class by providing the URI, link relation types, and additional attributes:
Retrieving URI Components
You can retrieve different components of the URI using the following methods:
Modifying URI Components
You can create a modified version of the link by using the following methods:
Rendering HTML Anchor Tags
To render the link as an HTML anchor tag, use the render method:
The render method returns a string containing the HTML anchor tag.
Link Attributes
You can retrieve and modify the link's relation types and additional attributes using the following methods:
You can create a modified version of the link with updated relation types and attributes using the following methods:
String Conversion
You can obtain the string representation of the link using the magic __toString method:
LinkProvider
The LinkProvider class is an implementation of the EvolvableLinkProviderInterface from the PSR-Link library. It is used to store and manage links.
First, import the LinkProvider class:
Create an instance of the LinkProvider class:
Adding Links
To add a link to the provider, use the withLink method:
You can chain multiple withLink calls to add multiple links:
Retrieving Links
To retrieve all the links in the provider, use the getLinks method:
The getLinks method returns an array of LinkInterface objects.
Removing Links
To remove a link from the provider, use the withoutLink method:
Filtering Links
To retrieve links based on their relationship, use the getLinksByRel method:
The getLinksByRel method returns an array of LinkInterface objects that have the specified relationship.
Adding Multiple Links
To add multiple links at once, use the withLinks method:
Removing Multiple Links
To remove multiple links at once, use the withoutLinks method:
The withoutLinks method takes an array of LinkInterface objects and removes them from the provider.