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.

Differences Between: [Versions 310 and 401] [Versions 39 and 401]

   1  <?php
   2  
   3  namespace Box\Spout\Writer\XLSX\Manager;
   4  
   5  use Box\Spout\Common\Manager\OptionsManagerAbstract;
   6  use Box\Spout\Writer\Common\Creator\Style\StyleBuilder;
   7  use Box\Spout\Writer\Common\Entity\Options;
   8  
   9  /**
  10   * Class OptionsManager
  11   * XLSX Writer options manager
  12   */
  13  class OptionsManager extends OptionsManagerAbstract
  14  {
  15      /** Default style font values */
  16      const DEFAULT_FONT_SIZE = 12;
  17      const DEFAULT_FONT_NAME = 'Calibri';
  18  
  19      /** @var StyleBuilder Style builder */
  20      protected $styleBuilder;
  21  
  22      /**
  23       * OptionsManager constructor.
  24       * @param StyleBuilder $styleBuilder
  25       */
  26      public function __construct(StyleBuilder $styleBuilder)
  27      {
  28          $this->styleBuilder = $styleBuilder;
  29          parent::__construct();
  30      }
  31  
  32      /**
  33       * {@inheritdoc}
  34       */
  35      protected function getSupportedOptions()
  36      {
  37          return [
  38              Options::TEMP_FOLDER,
  39              Options::DEFAULT_ROW_STYLE,
  40              Options::SHOULD_CREATE_NEW_SHEETS_AUTOMATICALLY,
  41              Options::SHOULD_USE_INLINE_STRINGS,
  42          ];
  43      }
  44  
  45      /**
  46       * {@inheritdoc}
  47       */
  48      protected function setDefaultOptions()
  49      {
  50          $defaultRowStyle = $this->styleBuilder
  51              ->setFontSize(self::DEFAULT_FONT_SIZE)
  52              ->setFontName(self::DEFAULT_FONT_NAME)
  53              ->build();
  54  
  55          $this->setOption(Options::TEMP_FOLDER, \sys_get_temp_dir());
  56          $this->setOption(Options::DEFAULT_ROW_STYLE, $defaultRowStyle);
  57          $this->setOption(Options::SHOULD_CREATE_NEW_SHEETS_AUTOMATICALLY, true);
  58          $this->setOption(Options::SHOULD_USE_INLINE_STRINGS, true);
  59      }
  60  }