Created
August 8, 2022 16:19
-
-
Save litzinger/80f55e8d28beedbf60e697f655d13539 to your computer and use it in GitHub Desktop.
localize vendor packages
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$iterator = new \RecursiveIteratorIterator( | |
new \RecursiveDirectoryIterator($addonDir, \RecursiveDirectoryIterator::SKIP_DOTS), | |
\RecursiveIteratorIterator::LEAVES_ONLY | |
); | |
download_and_extract_package('basee', 'Basee', $outputDir, $addonDir); | |
download_and_extract_package('file-field', 'FileField', $outputDir, $addonDir); | |
// Update the namespaces | |
foreach ($iterator as $name => $file) { | |
if ($file->isDir()) { | |
continue; | |
} else { | |
copy_file($name, $name, function ($contents) use ($namespacePrefix) { | |
$contents = str_replace('namespace Basee', 'namespace '. $namespacePrefix .'\Library\Basee', $contents); | |
$contents = str_replace('namespace Litzinger\FileField', 'namespace '. $namespacePrefix .'\Library\FileField', $contents); | |
$contents = str_replace('use Basee', 'use '. $namespacePrefix .'\Library\Basee', $contents); | |
return $contents; | |
}); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment