publisher.php 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. <?php namespace Laravel\CLI\Tasks\Bundle;
  2. use Laravel\File;
  3. use Laravel\Bundle;
  4. use FilesystemIterator;
  5. class Publisher {
  6. /**
  7. * Publish a bundle's assets to the public directory.
  8. *
  9. * @param string $bundle
  10. * @return void
  11. */
  12. public function publish($bundle)
  13. {
  14. $path = Bundle::path($bundle);
  15. $this->move($path.'public', PUBLIC_PATH.'bundles'.DS.$bundle);
  16. $this->move($path.'tests', TESTS_PATH.'cases'.DS.'bundles'.DS.$bundle);
  17. echo "Assets and tests published for bundle [$bundle].".PHP_EOL;
  18. }
  19. /**
  20. * Copy the contents of a bundle's assets to the public folder.
  21. *
  22. * @param string $source
  23. * @param string $destination
  24. * @return void
  25. */
  26. protected function move($source, $destination)
  27. {
  28. File::copy_dir($source, $destination);
  29. }
  30. /**
  31. * Get the "to" location of the bundle's assets.
  32. *
  33. * @param string $bundle
  34. * @return string
  35. */
  36. protected function to($bundle)
  37. {
  38. return PUBLIC_PATH.'bundles'.DS.$bundle.DS;
  39. }
  40. /**
  41. * Get the "from" location of the bundle's assets.
  42. *
  43. * @param string $bundle
  44. * @return string
  45. */
  46. protected function from($bundle)
  47. {
  48. return Bundle::path($bundle).'public';
  49. }
  50. }