configRepository->findSingleton() ?? new ShareConfiguration(); $config->setHost($data->host); $config->setShareName($data->shareName); $config->setBasePath($data->basePath); $config->setDomain($data->domain); $config->setUsername($data->username); $config->setEnabled($data->enabled); if (null !== $data->password && '' !== $data->password) { $config->setEncryptedPassword($this->tokenEncryptor->encrypt($data->password)); } $this->em->persist($config); $this->em->flush(); $result = new ShareSettings(); $result->host = $config->getHost(); $result->shareName = $config->getShareName(); $result->basePath = $config->getBasePath(); $result->domain = $config->getDomain(); $result->username = $config->getUsername(); $result->enabled = $config->isEnabled(); $result->hasPassword = $config->hasPassword(); return $result; } }