Golonka\BBCode\BBCodeParser::setParser PHP Method

setParser() public method

This can be used for new parsers or overwriting existing ones.
public setParser ( string $name, string $pattern, string $replace, string $content ) : void
$name string Parser name
$pattern string Pattern
$replace string Replace pattern
$content string Parsed text pattern
return void
    public function setParser($name, $pattern, $replace, $content)
    {
        $this->parsers[$name] = array('pattern' => $pattern, 'replace' => $replace, 'content' => $content);
        $this->enabledParsers[$name] = array('pattern' => $pattern, 'replace' => $replace, 'content' => $content);
    }

Usage Example

 /**
  * Adds emoticons
  * 
  * @return void
  */
 protected function addSmiles()
 {
     $path = $this->container->get('templating.helper.assets')->getUrl('/bundles/valantirforum/plugin/sceditor/emoticons/');
     foreach ($this->smiles as $smile) {
         $tag = '<img src="' . $path . $smile['file'] . '" alt="' . $smile['name'] . '">';
         $this->parser->setParser($smile['name'], $smile['pattern'], $tag, $smile['content']);
     }
 }
All Usage Examples Of Golonka\BBCode\BBCodeParser::setParser