publisher.php 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  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', path('public').'bundles'.DS.$bundle);
  16. echo "Assets published for bundle [$bundle].".PHP_EOL;
  17. }
  18. /**
  19. * Copy the contents of a bundle's assets to the public folder.
  20. *
  21. * @param string $source
  22. * @param string $destination
  23. * @return void
  24. */
  25. protected function move($source, $destination)
  26. {
  27. File::cpdir($source, $destination);
  28. }
  29. /**
  30. * Get the "to" location of the bundle's assets.
  31. *
  32. * @param string $bundle
  33. * @return string
  34. */
  35. protected function to($bundle)
  36. {
  37. return path('public').'bundles'.DS.$bundle.DS;
  38. }
  39. /**
  40. * Get the "from" location of the bundle's assets.
  41. *
  42. * @param string $bundle
  43. * @return string
  44. */
  45. protected function from($bundle)
  46. {
  47. return Bundle::path($bundle).'public';
  48. }
  49. }