SproutCMS

This is the code documentation for the SproutCMS project

class Lnk

This is a system of portable, extensible link management.

The system is based around the "link specification", which is a string.
Link specifications should be stored in a TEXT field.

These specs relate to classes which extend LinkSpec.
The class name needs to start with "LinkSpec" too.

Extending this class

<?php
/**
* New class description goes here
* 
* @author Your Name, 2024-11-25
**/
class NewClassName extends Lnk {
    
    /**
    * Attempts to convert a link specification into a URL
    * 
    * This differs in behaviour to `Lnk::url` as it will return null if the spec is
    * empty, but *not* malformed; it still throws an InvalidArgumentException in that case.
    * It will also return null if a RowMissingException is thrown by the link spec instance
    * during processing.
    * 
    * Helpful when you wish to avoid breaking pages when someone deletes the linked record, e.g. a blog post,
    * without updating the corresponding link(s).
    **/
    public function tryUrl (string $spec) {
        // Method code goes here
    }
    
    /**
    * Return an opening A tag for a link specification.
    **/
    public function atag (string $spec, array $attributes) {
        // Method code goes here
    }
    
    /**
    * Output the name of the type of the linkspec.
    **/
    public function typename (string $spec) {
        // Method code goes here
    }
    
    /**
    * Check if the data supplied for a spec is valid.
    **/
    public function valid (string $spec) {
        // Method code goes here
    }
    
    /**
    * For a given link specification, instance it's class
    **/
    private function instance (string $spec) {
        // Method code goes here
    }
    
    /**
    * Convert a link specification into a URL.
    **/
    public function url (string $spec) {
        // Method code goes here
    }
    
    /**
    * Output html for editing link specifications.
    * This is designed for admin use.
    **/
    public function editform (string $field_name, string $curr_spec, bool $required) {
        // Method code goes here
    }
    
    /**
    * Some edit forms require additional javascript via the {@see needs} helper
    * Load in all of these requirements for all LinkSpec classes
    **/
    public function editformNeeds () {
        // Method code goes here
    }
    
}
?>