name = $image->getName(); $this->type = $image->getType(); $this->remotePc = $image->isRemotePc(); $this->isGlobal = $image->isGlobal(); $this->version = $image->getVersion(); if ($image->getSoftwareProfile()) { $this->softwareProfile = new SoftwareProfileOutput($image->getSoftwareProfile()); } if ($image->getClient()) { $this->client = new ClientOutput($image->getClient()); } if ($image->getImageImageRepositories()) { $this->imageRepositories = array_map(fn($imageImageRepository) => new ImageImageRepositoryOutput($imageImageRepository), $image->getImageImageRepositories()->toArray()); } if ($image->getParent()) { $this->parent = new self($image->getParent()); } } public function createOrUpdateEntity(?Image $image = null): Image { if (!$image) { $image = new Image(); } $image->setName($this->name); $image->setType($this->type); if ($this->softwareProfile) { $image->setSoftwareProfile($this->softwareProfile->getEntity()); } if ($this->client) { $image->setClient($this->client->getEntity()); } if ($this->imageRepositories) { foreach ($this->imageRepositories as $imageRepository) { $aux = new ImageImageRepository(); $aux->setImage($image); $aux->setRepository($imageRepository->getEntity()); $aux->setStatus(''); if (!$image->containsImageImageRepository($aux)) { $image->addImageImageRepository($aux); } } } $image->setRemotePc($this->remotePc); $image->setIsGlobal($this->isGlobal); $partitionInfo = []; if ($this->partition) { /** @var Partition $partition */ $partition = $this->partition->getEntity(); $partitionInfo["numDisk"] = $partition->getDiskNumber(); $partitionInfo["numPartition"] = $partition->getPartitionNumber(); $partitionInfo["partitionCode"] = $partition->getPartitionCode(); $partitionInfo["filesystem"] = $partition->getFilesystem(); $partitionInfo["osName"] = $partition->getOperativeSystem()?->getName(); $image->setPartitionInfo(json_encode($partitionInfo)); } return $image; } }