URL Extension

Before reading this, it may be prudent to first read about Centum’s URL component.

This extension provides a quick shortcut to the Centum\Url\Url class in the form of a function.

First, the extension needs to be added to Twig:

use Centum\Twig\UrlExtension;
use Centum\Url\Url;
use Twig\Environment;

/** @var string $baseUri */

$url = new Url($baseUri);

/** @var Environment $twig */

$twig->addExtension(
    new UrlExtension($url)
);

Then within your Twig files, you can call the url() function which will effectively call $url->get() to display all of the current flash messages:

<a href="{{ url('/link/to/a/page')|escape('html_attr') }}">Link</a>