Example linkify module

The following example module demonstrates how to turn text that appears in changelist, job, or code review descriptions, comments, and activity entries into links.

  1. Create a folder called Rickroll in the module folder.
  2. Create the file Module.php within module/Rickroll and edit it to contain:

    <?php
    /**
    * Helix Swarm
    *
    * @copyright 2014 Perforce Software. All rights reserved.
    * @license Please see LICENSE.txt in top-level folder of this distribution.
    * @version <release>/<patch>
    */
    namespace Rickroll; use Application\Filter\Linkify;
    class Module
    {
    public function onBootstrap()
    {
    Linkify::addCallback(
    function ($value, $escaper) {
    if (strcasecmp($value, 'rickroll')) {
    // not a hit; tell caller we did not handle this one
    return false;
    }
    return '<a target="_new" href="https://www.youtube.com/watch?v=dQw4w9WgXcQ">'
    . $escaper->escapeHtml($value) . "</a>";
    },
    'rickroll',
    strlen('rickroll')
    );
    }

    public function getConfig()
    {
    return array();
    }
    }

    This file achieves several things. It: