コード例 #1
0
ファイル: CommandsRenderer.php プロジェクト: bigwhoop/trumpet
 /**
  * {@inheritdoc}
  */
 public function render(Slide $slide)
 {
     $lines = explode("\n", str_replace("\r", '', $slide->content));
     $out = [];
     foreach ($lines as $line) {
         if (0 === strpos($line, self::COMMAND_PREFIX)) {
             $command = substr($line, strlen(self::COMMAND_PREFIX));
             list($commandName, $commandParams) = explode(' ', $command, 2);
             if ($this->commandHandler->hasCommand($commandName)) {
                 $line = $this->commandHandler->execute($commandName, new CommandParams($commandParams), $this->executionContext);
             }
         }
         $out[] = $line;
     }
     return implode("\n", $out);
 }