PHP code example of fof / links

1. Go to this page and download the library: Download fof/links library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

fof / links example snippets


use FoF\Links\Extend\LinksOverride;
use FoF\Links\LinkDefinition;

return [
    // Other extenders...
    
    (new LinksOverride())
        ->addLinks([
            LinkDefinition::make()
                ->withId(1)
                ->withTranslationKey('my-extension.link')
                ->withUrl('/my-page')
                ->withIcon('fas fa-link')
                ->withIsInternal(true)
        ])
];

use FoF\Links\Extend\LinksOverride;
use FoF\Links\LinkDefinition;

$parent = LinkDefinition::make()
    ->withId(1)
    ->withTranslationKey('my-extension.parent')
    ->withUrl('/parent');

$child1 = LinkDefinition::make()
    ->withId(2)
    ->withTranslationKey('my-extension.child1')
    ->withUrl('/child1');

$child2 = LinkDefinition::make()
    ->withId(3)
    ->withTranslationKey('my-extension.child2')
    ->withUrl('/child2');

$parent->addChild($child1);
$parent->addChild($child2);

return [
    // Other extenders...
    
    (new LinksOverride())
        ->addLinks([$parent])
];

use FoF\Links\Extend\LinksOverride;
use FoF\Links\LinkDefinition;

class MyLinksProvider
{
    public function __invoke()
    {
        return [
            LinkDefinition::make()
                ->withId(1)
                ->withTranslationKey('my-extension.link')
                ->withUrl('/my-page')
        ];
    }
}

return [
    // Other extenders...
    
    (new LinksOverride())
        ->addLinks(MyLinksProvider::class)
];
bash
composer update fof/links
php flarum cache:clear