* @copyright Since 2007 PrestaShop SA and Contributors * @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0) */ namespace PrestaShop\Module\AutoUpgrade; use Exception; use PrestaShop\Module\AutoUpgrade\UpgradeTools\Translator; class Workspace { /** * @var Translator */ private $translator; /** * @var string[] List of paths used by autoupgrade */ private $paths; /** * @param string[] $paths */ public function __construct(Translator $translator, array $paths) { $this->translator = $translator; $this->paths = $paths; } public function createFolders(): void { foreach ($this->paths as $path) { if (!file_exists($path) && !@mkdir($path)) { throw new Exception($this->translator->trans('Unable to create directory %s', [$path])); } if (!is_writable($path)) { throw new Exception($this->translator->trans('Cannot write to the directory. Please ensure you have the necessary write permissions on "%s".', [$path])); } } } }