|
@@ -2,15 +2,19 @@
|
|
|
|
|
|
|
|
namespace App\Service\Typo3;
|
|
namespace App\Service\Typo3;
|
|
|
|
|
|
|
|
|
|
+use Path\Exception\FileNotFoundException;
|
|
|
|
|
+use Path\Exception\IOException;
|
|
|
|
|
+use Path\Path;
|
|
|
|
|
+
|
|
|
/**
|
|
/**
|
|
|
* Opérations sur le fichier Bind, qui gère entre autres l'adressage DNS lié aux sous-domaines.
|
|
* Opérations sur le fichier Bind, qui gère entre autres l'adressage DNS lié aux sous-domaines.
|
|
|
*
|
|
*
|
|
|
* @codeCoverageIgnore
|
|
* @codeCoverageIgnore
|
|
|
*/
|
|
*/
|
|
|
-class BindFileService
|
|
|
|
|
|
|
+readonly class BindFileService
|
|
|
{
|
|
{
|
|
|
public function __construct(
|
|
public function __construct(
|
|
|
- readonly private string $bindfileBufferFile,
|
|
|
|
|
|
|
+ private string $bindfileBufferFile,
|
|
|
) {
|
|
) {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -18,12 +22,13 @@ class BindFileService
|
|
|
* Append the subdomain to the buffer file.
|
|
* Append the subdomain to the buffer file.
|
|
|
*
|
|
*
|
|
|
* A cron consumes this file each 5 minutes to complete the bind file /etc/bind/zones/opentalent.fr.db
|
|
* A cron consumes this file each 5 minutes to complete the bind file /etc/bind/zones/opentalent.fr.db
|
|
|
|
|
+ * @param string $subdomain
|
|
|
|
|
+ * @throws FileNotFoundException
|
|
|
|
|
+ * @throws IOException
|
|
|
*/
|
|
*/
|
|
|
public function registerSubdomain(string $subdomain): void
|
|
public function registerSubdomain(string $subdomain): void
|
|
|
{
|
|
{
|
|
|
- $fsd = fopen($this->bindfileBufferFile, 'ab+');
|
|
|
|
|
- fwrite($fsd, $subdomain);
|
|
|
|
|
- fwrite($fsd, "\n");
|
|
|
|
|
- fclose($fsd);
|
|
|
|
|
|
|
+ $bindFile = new Path($this->bindfileBufferFile);
|
|
|
|
|
+ $bindFile->putContent($subdomain . '\n', true);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|