[ Index ]

PHP Cross Reference of phpBB-3.3.14-deutsch

title

Body

[close]

/vendor/s9e/text-formatter/src/Configurator/TemplateNormalizations/ -> OptimizeNestedConditionals.php (source)

   1  <?php
   2  
   3  /**
   4  * @package   s9e\TextFormatter
   5  * @copyright Copyright (c) 2010-2022 The s9e authors
   6  * @license   http://www.opensource.org/licenses/mit-license.php The MIT License
   7  */
   8  namespace s9e\TextFormatter\Configurator\TemplateNormalizations;
   9  
  10  use DOMElement;
  11  
  12  /**
  13  * Optimize xsl:choose elements by integrating the content of another xsl:choose element located
  14  * in their xsl:otherwise part
  15  *
  16  * Will move child nodes from //xsl:choose/xsl:otherwise/xsl:choose to their great-grandparent as
  17  * long as the inner xsl:choose has no siblings. Good for XSLT stylesheets because it reduces the
  18  * number of nodes, not-so-good for the PHP renderer when it prevents from optimizing branch
  19  * tables by mixing the branch keys
  20  */
  21  class OptimizeNestedConditionals extends AbstractNormalization
  22  {
  23      /**
  24      * {@inheritdoc}
  25      */
  26      protected $queries = ['//xsl:choose/xsl:otherwise[count(node()) = 1]/xsl:choose'];
  27  
  28      /**
  29      * {@inheritdoc}
  30      */
  31  	protected function normalizeElement(DOMElement $element)
  32      {
  33          $otherwise   = $element->parentNode;
  34          $outerChoose = $otherwise->parentNode;
  35  
  36          while ($element->firstChild)
  37          {
  38              $outerChoose->appendChild($element->removeChild($element->firstChild));
  39          }
  40  
  41          $outerChoose->removeChild($otherwise);
  42      }
  43  }


Generated: Mon Nov 25 19:05:08 2024 Cross-referenced by PHPXref 0.7.1