![]() Server : Apache System : Linux server2.corals.io 4.18.0-348.2.1.el8_5.x86_64 #1 SMP Mon Nov 15 09:17:08 EST 2021 x86_64 User : corals ( 1002) PHP Version : 7.4.33 Disable Function : exec,passthru,shell_exec,system Directory : /home/corals/mautic.corals.io/app/bundles/ReportBundle/Model/ |
<?php namespace Mautic\ReportBundle\Model; use Mautic\CoreBundle\Exception\FilePathException; use Mautic\CoreBundle\Helper\CoreParametersHelper; use Mautic\CoreBundle\Helper\FilePathResolver; use Mautic\ReportBundle\Exception\FileIOException; class ExportHandler { /** * @var string */ private $dir; public function __construct( CoreParametersHelper $coreParametersHelper, private FilePathResolver $filePathResolver ) { $this->dir = $coreParametersHelper->get('report_temp_dir'); } /** * @return bool|resource * * @throws FileIOException */ public function getHandler($fileName) { $path = $this->getPath($fileName); if (false === ($handler = @fopen($path, 'a'))) { throw new FileIOException('Could not open file '.$path); } return $handler; } /** * @param resource $handler */ public function closeHandler($handler): void { fclose($handler); } /** * @param string $fileName */ public function removeFile($fileName): void { try { $path = $this->getPath($fileName); $this->filePathResolver->delete($path); } catch (FileIOException) { } } /** * @throws FileIOException */ public function getPath($fileName): string { try { $this->filePathResolver->createDirectory($this->dir); } catch (FilePathException $e) { throw new FileIOException('Could not create directory '.$this->dir, 0, $e); } return $this->dir.'/'.$fileName.'.csv'; } }