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 311 and 401] [Versions 39 and 401] [Versions 401 and 402] [Versions 401 and 403]

   1  <?php
   2  
   3  namespace PhpOffice\PhpSpreadsheet\Shared\Escher\DgContainer;
   4  
   5  class SpgrContainer
   6  {
   7      /**
   8       * Parent Shape Group Container.
   9       *
  10       * @var null|SpgrContainer
  11       */
  12      private $parent;
  13  
  14      /**
  15       * Shape Container collection.
  16       *
  17       * @var array
  18       */
  19      private $children = [];
  20  
  21      /**
  22       * Set parent Shape Group Container.
  23       */
  24      public function setParent(?self $parent): void
  25      {
  26          $this->parent = $parent;
  27      }
  28  
  29      /**
  30       * Get the parent Shape Group Container if any.
  31       */
  32      public function getParent(): ?self
  33      {
  34          return $this->parent;
  35      }
  36  
  37      /**
  38       * Add a child. This will be either spgrContainer or spContainer.
  39       *
  40       * @param mixed $child
  41       */
  42      public function addChild($child): void
  43      {
  44          $this->children[] = $child;
  45          $child->setParent($this);
  46      }
  47  
  48      /**
  49       * Get collection of Shape Containers.
  50       */
  51      public function getChildren()
  52      {
  53          return $this->children;
  54      }
  55  
  56      /**
  57       * Recursively get all spContainers within this spgrContainer.
  58       *
  59       * @return SpgrContainer\SpContainer[]
  60       */
  61      public function getAllSpContainers()
  62      {
  63          $allSpContainers = [];
  64  
  65          foreach ($this->children as $child) {
  66              if ($child instanceof self) {
  67                  $allSpContainers = array_merge($allSpContainers, $child->getAllSpContainers());
  68              } else {
  69                  $allSpContainers[] = $child;
  70              }
  71          }
  72  
  73          return $allSpContainers;
  74      }
  75  }