Bolt\Twig\Handler\AdminHandler::ymllink PHP Метод

    public function ymllink($str, $safe)
    {
        // There is absolutely no way anyone could possibly need this in a "safe" context
        if ($safe) {
            return null;
        }
        $matches = [];
        if (preg_match('/ ([a-z0-9_-]+\\.yml)/i', $str, $matches)) {
            $path = $this->app['url_generator']->generate('fileedit', ['namespace' => 'config', 'file' => $matches[1]]);
            $link = sprintf(' <a href="%s">%s</a>', $path, $matches[1]);
            $str = preg_replace('/ ([a-z0-9_-]+\\.yml)/i', $link, $str);
        }
        return $str;
    }

Usage Example

Пример #1
0
 public function testYmllink()
 {
     $app = $this->getApp();
     $handler = new AdminHandler($app);
     $result = $handler->ymllink(' config.yml', false);
     $this->assertSame(' <a href="/bolt/file/edit/config/config.yml">config.yml</a>', $result);
 }