public LinkGenerator::generate($text, Url $url)
For anonymous users, the "active" class will be calculated on the server, because most sites serve each anonymous user the same cached page anyway. For authenticated users, the "active" class will be calculated on the client (through JavaScript), only data- attributes are added to links to prevent breaking the render cache. The JavaScript is added in system_page_attachments().
Overrides LinkGeneratorInterface::generate
See also
system_page_attac