Thunder\Shortcode\Processor\Processor::process PHP Method

process() public method

Entry point for shortcode processing. Implements iterative algorithm for both limited and unlimited number of iterations.
public process ( string $text ) : string
$text string Text to process
return string
    public function process($text)
    {
        $iterations = $this->maxIterations === null ? 1 : $this->maxIterations;
        $context = new ProcessorContext();
        $context->processor = $this;
        while ($iterations--) {
            $context->iterationNumber++;
            $newText = $this->processIteration($text, $context, null);
            if ($newText === $text) {
                break;
            }
            $text = $newText;
            $iterations += $this->maxIterations === null ? 1 : 0;
        }
        return $text;
    }

Usage Example

 /**
  * Process shortcodes after Grav's processing, but before caching
  *
  * @param Event $e
  */
 public function onPageContentProcessed(Event $e)
 {
     $page = $e['page'];
     $config = $this->mergeConfig($page);
     $this->active = $config->get('active', true);
     // if the plugin is not active (either global or on page) exit
     if (!$this->active) {
         return;
     }
     switch ($config->get('parser')) {
         case 'regular':
             $parser = 'Thunder\\Shortcode\\Parser\\RegularParser';
             break;
         case 'wordpress':
             $parser = 'Thunder\\Shortcode\\Parser\\WordpressParser';
             break;
         default:
             $parser = 'Thunder\\Shortcode\\Parser\\RegexParser';
             break;
     }
     if ($page && $config->get('enabled')) {
         $content = $e['page']->getRawContent();
         $processor = new Processor(new $parser(new CommonSyntax()), $this->handlers);
         $processed_content = $processor->process($content);
         $e['page']->setRawContent($processed_content);
     }
 }
All Usage Examples Of Thunder\Shortcode\Processor\Processor::process