BindFileService.php 848 B

123456789101112131415161718192021222324252627282930313233343536
  1. <?php
  2. declare(strict_types=1);
  3. namespace App\Service\Typo3;
  4. use Path\Exception\FileNotFoundException;
  5. use Path\Exception\IOException;
  6. use Path\Path;
  7. /**
  8. * Opérations sur le fichier Bind, qui gère entre autres l'adressage DNS lié aux sous-domaines.
  9. *
  10. * @codeCoverageIgnore
  11. */
  12. readonly class BindFileService
  13. {
  14. public function __construct(
  15. private string $bindfileBufferFile,
  16. ) {
  17. }
  18. /**
  19. * Append the subdomain to the buffer file.
  20. *
  21. * A cron consumes this file each 5 minutes to complete the bind file /etc/bind/zones/opentalent.fr.db
  22. *
  23. * @throws FileNotFoundException
  24. * @throws IOException
  25. */
  26. public function registerSubdomain(string $subdomain): void
  27. {
  28. $bindFile = new Path($this->bindfileBufferFile);
  29. $bindFile->putContent($subdomain.'\n', true);
  30. }
  31. }