Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 3.11.x will end 14 Nov 2022 (12 months plus 6 months extension).
  • Bug fixes for security issues in 3.11.x will end 13 Nov 2023 (18 months plus 12 months extension).
  • PHP version: minimum PHP 7.3.0 Note: minimum PHP version has increased since Moodle 3.10. PHP 7.4.x is supported too.

Differences Between: [Versions 310 and 311] [Versions 311 and 400] [Versions 311 and 401] [Versions 311 and 402] [Versions 311 and 403] [Versions 39 and 311]

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