[ Index ]

PHP Cross Reference of DokuWiki

title

Body

[close]

/inc/Parsing/ParserMode/ -> Entity.php (source)

   1  <?php
   2  
   3  namespace dokuwiki\Parsing\ParserMode;
   4  
   5  use dokuwiki\Parsing\Lexer\Lexer;
   6  
   7  class Entity extends AbstractMode
   8  {
   9      protected $entities = [];
  10      protected $pattern = '';
  11  
  12      /**
  13       * Entity constructor.
  14       * @param string[] $entities
  15       */
  16      public function __construct($entities)
  17      {
  18          $this->entities = $entities;
  19      }
  20  
  21  
  22      /** @inheritdoc */
  23      public function preConnect()
  24      {
  25          if (!count($this->entities) || $this->pattern != '') return;
  26  
  27          $sep = '';
  28          foreach ($this->entities as $entity) {
  29              $this->pattern .= $sep . Lexer::escape($entity);
  30              $sep = '|';
  31          }
  32      }
  33  
  34      /** @inheritdoc */
  35      public function connectTo($mode)
  36      {
  37          if (!count($this->entities)) return;
  38  
  39          if (strlen($this->pattern) > 0) {
  40              $this->Lexer->addSpecialPattern($this->pattern, $mode, 'entity');
  41          }
  42      }
  43  
  44      /** @inheritdoc */
  45      public function getSort()
  46      {
  47          return 260;
  48      }
  49  }