rows = new ArrayCollection(); $this->cache = []; $this->createdDate = new \DateTime(); $this->updateModifiedDate(); } public function getId(): ?int { return $this->id; } /** * @return Collection|AGridRow[] */ public function getRows(): Collection { return $this->rows; } public function addRow(AGridRow $row): self { if (!$this->rows->contains($row)) { $this->rows[] = $row; $row->setParentContainer($this); } return $this; } public function removeRow(AGridRow $row): self { if ($this->rows->contains($row)) { $this->rows->removeElement($row); // set the owning side to null (unless already changed) if ($row->getParentContainer() === $this) { $row->setParentContainer(null); } } return $this; } public function getCaches() { return $this->cache; } public function getCache(string $lang = null, string $resolution = null) { if($lang == null) $lang = 'default'; if($resolution == null) $resolution = 'default'; //on a l'information pour la langue et la résolution concernée if(isset($this->cache[$lang][$resolution]) && $this->cache[$lang][$resolution] != null) return $this->cache[$lang][$resolution]; //on regarde si on à l'information pour la résolution par defaut if(isset($this->cache[$lang]['default']) && $this->cache[$lang]['default'] != null) return $this->cache[$lang]['default']; //on regarde si on a l'information pour la langue par defaut if(isset($this->cache['default'][$resolution]) && $this->cache['default'][$resolution] != null) return $this->cache['default'][$resolution]; //on regarde si on a l'information pour la langue et la résolution par defaut if(isset($this->cache['default']['default']) && $this->cache['default']['default'] != null) return $this->cache['default']['default']; return ''; } /** * @param string $lang * @param string $resolution * @param $value * @return $this */ public function addCache(string $lang, string $resolution, $value) { if($lang == null) $lang = 'default'; if($resolution == null) $resolution = 'default'; $this->cache[$lang][$resolution] = $value; return $this; } public function getCreatedDate(): ?\DateTimeInterface { return $this->createdDate; } public function setCreatedDate(\DateTimeInterface $createdDate): self { $this->createdDate = $createdDate; return $this; } public function getUpdatedDate(): ?\DateTimeInterface { return $this->updatedDate; } public function updateModifiedDate(){ $this->updatedDate = new \DateTime(); if ($this->updatedDate === null) $this->updatedDate = new \DateTime('now'); } public function rowsFirstLevel(){ $firstLevel = array(); foreach ($this->rows as $row){ /** * @var $row AGridRow */ if($row->getParentCol() == null) $firstLevel[] = $row; } return $firstLevel; } public function setCache(array $cache): self { $this->cache = $cache; return $this; } public function setUpdatedDate(\DateTimeInterface $updatedDate): self { $this->updatedDate = $updatedDate; return $this; } }