copy-stubs-to-component.php 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. <?php
  2. /*
  3. * This file is part of the Symfony package.
  4. *
  5. * (c) Fabien Potencier <fabien@symfony.com>
  6. *
  7. * For the full copyright and license information, please view the LICENSE
  8. * file that was distributed with this source code.
  9. */
  10. use Symfony\Component\Filesystem\Filesystem;
  11. use Symfony\Component\Icu\IcuData;
  12. use Symfony\Component\Intl\Intl;
  13. require_once __DIR__ . '/common.php';
  14. require_once __DIR__ . '/autoload.php';
  15. if (1 !== $GLOBALS['argc']) {
  16. bailout(<<<MESSAGE
  17. Usage: php copy-stubs-to-component.php
  18. Copies stub files created with create-stubs.php to the Icu component.
  19. For running this script, the intl extension must be loaded and all vendors
  20. must have been installed through composer:
  21. composer install --dev
  22. MESSAGE
  23. );
  24. }
  25. echo LINE;
  26. echo centered("ICU Resource Bundle Stub Update") . "\n";
  27. echo LINE;
  28. if (!class_exists('\Symfony\Component\Icu\IcuData')) {
  29. bailout('You must run "composer update --dev" before running this script.');
  30. }
  31. $stubBranch = '1.0.x';
  32. if (!IcuData::isStubbed()) {
  33. bailout("Please switch to the Icu component branch $stubBranch.");
  34. }
  35. $filesystem = new Filesystem();
  36. $sourceDir = sys_get_temp_dir() . '/icu-stubs';
  37. $targetDir = IcuData::getResourceDirectory();
  38. if (!$filesystem->exists($sourceDir)) {
  39. bailout("The directory $sourceDir does not exist. Please run create-stubs.php first.");
  40. }
  41. $filesystem->remove($targetDir);
  42. echo "Copying files from $sourceDir to $targetDir...\n";
  43. $filesystem->mirror($sourceDir, $targetDir);
  44. echo "Done.\n";