Search moodle.org's
Developer Documentation

See Release Notes
Long Term Support Release

  • Bug fixes for general core bugs in 4.1.x will end 13 November 2023 (12 months).
  • Bug fixes for security issues in 4.1.x will end 10 November 2025 (36 months).
  • PHP version: minimum PHP 7.4.0 Note: minimum PHP version has increased since Moodle 4.0. PHP 8.0.x is supported too.
   1  <?php
   2  
   3  namespace Box\Spout\Writer\XLSX\Creator;
   4  
   5  use Box\Spout\Common\Helper\Escaper;
   6  use Box\Spout\Common\Helper\StringHelper;
   7  use Box\Spout\Common\Manager\OptionsManagerInterface;
   8  use Box\Spout\Writer\Common\Creator\InternalEntityFactory;
   9  use Box\Spout\Writer\Common\Entity\Options;
  10  use Box\Spout\Writer\Common\Helper\ZipHelper;
  11  use Box\Spout\Writer\XLSX\Helper\FileSystemHelper;
  12  
  13  /**
  14   * Class HelperFactory
  15   * Factory for helpers needed by the XLSX Writer
  16   */
  17  class HelperFactory extends \Box\Spout\Common\Creator\HelperFactory
  18  {
  19      /**
  20       * @param OptionsManagerInterface $optionsManager
  21       * @param InternalEntityFactory $entityFactory
  22       * @return FileSystemHelper
  23       */
  24      public function createSpecificFileSystemHelper(OptionsManagerInterface $optionsManager, InternalEntityFactory $entityFactory)
  25      {
  26          $tempFolder = $optionsManager->getOption(Options::TEMP_FOLDER);
  27          $zipHelper = $this->createZipHelper($entityFactory);
  28          $escaper = $this->createStringsEscaper();
  29  
  30          return new FileSystemHelper($tempFolder, $zipHelper, $escaper);
  31      }
  32  
  33      /**
  34       * @param InternalEntityFactory $entityFactory
  35       * @return ZipHelper
  36       */
  37      private function createZipHelper(InternalEntityFactory $entityFactory)
  38      {
  39          return new ZipHelper($entityFactory);
  40      }
  41  
  42      /**
  43       * @return Escaper\XLSX
  44       */
  45      public function createStringsEscaper()
  46      {
  47          return new Escaper\XLSX();
  48      }
  49  
  50      /**
  51       * @return StringHelper
  52       */
  53      public function createStringHelper()
  54      {
  55          return new StringHelper();
  56      }
  57  }