get(\Magento\Framework\Filesystem::class); $fullDirectoryPath = $filesystem->getDirectoryRead(Magento\Framework\App\Filesystem\DirectoryList::PUB) ->getAbsolutePath() . $directoryName; $mediaDirectory = $filesystem->getDirectoryWrite(Magento\Framework\App\Filesystem\DirectoryList::MEDIA); $wysiwygDir = $mediaDirectory->getAbsolutePath() . 'wysiwyg'; $mediaDirectory->delete($wysiwygDir); if (!is_dir($fullDirectoryPath)) { mkdir($fullDirectoryPath); } if (is_dir($fullDirectoryPath) && !is_dir($wysiwygDir)) { symlink($fullDirectoryPath, $wysiwygDir); }