theme.php 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. use Magento\Framework\Component\ComponentRegistrar;
  7. $objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager();
  8. /* @var \Magento\Framework\Filesystem $filesystem */
  9. $filesystem = $objectManager->get(\Magento\Framework\Filesystem::class);
  10. $appDir = $filesystem->getDirectoryWrite(\Magento\Framework\App\Filesystem\DirectoryList::APP);
  11. if (!function_exists('rcopy')) {
  12. /**
  13. * Recursively copy files from one directory to another
  14. *
  15. * @param string $src - Source of files being moved
  16. * @param string $destination - Destination of files being moved
  17. * @return bool
  18. */
  19. function rcopy($src, $destination)
  20. {
  21. // If source is not a directory stop processing
  22. if (!is_dir($src)) {
  23. return false;
  24. }
  25. // If the destination directory does not exist create it
  26. // If the destination directory could not be created stop processing
  27. if (!is_dir($destination)) {
  28. if (!mkdir($destination)) {
  29. return false;
  30. }
  31. }
  32. // Open the source directory to read in files
  33. $iterator = new DirectoryIterator($src);
  34. foreach ($iterator as $file) {
  35. if ($file->isFile()) {
  36. copy($file->getRealPath(), $destination . '/' . $file->getFilename());
  37. } else if (!$file->isDot() && $file->isDir()) {
  38. rcopy($file->getRealPath(), $destination . '/' . $file);
  39. }
  40. }
  41. }
  42. }
  43. /** @var ComponentRegistrar $registrar */
  44. $registrar = $objectManager->get(ComponentRegistrar::class);
  45. //rcopy(
  46. // __DIR__ . '/zoom1',
  47. // $appDir->getAbsolutePath() . 'design/frontend/Magento/zoom1'
  48. //);
  49. if (!$registrar->getPath(ComponentRegistrar::THEME, 'frontend/Magento/zoom1')) {
  50. ComponentRegistrar::register(
  51. ComponentRegistrar::THEME,
  52. 'frontend/Magento/zoom1',
  53. __DIR__ . '/zoom1'
  54. );
  55. }
  56. //rcopy(
  57. // __DIR__ . '/zoom2',
  58. // $appDir->getAbsolutePath() . 'design/frontend/Magento/zoom2'
  59. //);
  60. if (!$registrar->getPath(ComponentRegistrar::THEME, 'frontend/Magento/zoom2')) {
  61. ComponentRegistrar::register(
  62. ComponentRegistrar::THEME,
  63. 'frontend/Magento/zoom2',
  64. __DIR__ . '/zoom2'
  65. );
  66. }
  67. //rcopy(
  68. // __DIR__ . '/zoom3',
  69. // $appDir->getAbsolutePath() . 'design/frontend/Magento/zoom3'
  70. //);
  71. if (!$registrar->getPath(ComponentRegistrar::THEME, 'frontend/Magento/zoom3')) {
  72. ComponentRegistrar::register(
  73. ComponentRegistrar::THEME,
  74. 'frontend/Magento/zoom3',
  75. __DIR__ . '/zoom3'
  76. );
  77. }
  78. /** @var \Magento\Theme\Model\Theme\Registration $themeRegistration */
  79. $themeRegistration = $objectManager->get(\Magento\Theme\Model\Theme\Registration::class);
  80. $themeRegistration->register();