Symlink.php 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\Framework\App\View\Asset\MaterializationStrategy;
  7. use Magento\Framework\App\Filesystem\DirectoryList;
  8. use Magento\Framework\Filesystem\Directory\WriteInterface;
  9. use Magento\Framework\View\Asset;
  10. class Symlink implements StrategyInterface
  11. {
  12. /**
  13. * Publish file
  14. *
  15. * @param WriteInterface $sourceDir
  16. * @param WriteInterface $targetDir
  17. * @param string $sourcePath
  18. * @param string $destinationPath
  19. * @return bool
  20. */
  21. public function publishFile(
  22. WriteInterface $sourceDir,
  23. WriteInterface $targetDir,
  24. $sourcePath,
  25. $destinationPath
  26. ) {
  27. return $sourceDir->createSymlink($sourcePath, $destinationPath, $targetDir);
  28. }
  29. /**
  30. * Whether the strategy can be applied
  31. *
  32. * @param Asset\LocalInterface $asset
  33. * @return bool
  34. */
  35. public function isSupported(Asset\LocalInterface $asset)
  36. {
  37. $sourceParts = explode('/', $asset->getSourceFile());
  38. if (in_array(DirectoryList::TMP_MATERIALIZATION_DIR, $sourceParts)) {
  39. return false;
  40. }
  41. return true;
  42. }
  43. }