|
18 | 18 | namespace TYPO3\CMS\ContentBlocks\Loader; |
19 | 19 |
|
20 | 20 | use Symfony\Component\DependencyInjection\Attribute\Autowire; |
21 | | -use Symfony\Component\Filesystem\Exception\IOException; |
22 | | -use Symfony\Component\Filesystem\Filesystem; |
23 | 21 | use Symfony\Component\Finder\Finder; |
24 | 22 | use Symfony\Component\Yaml\Yaml; |
25 | 23 | use TYPO3\CMS\ContentBlocks\Basics\BasicsLoader; |
|
37 | 35 | use TYPO3\CMS\Core\Cache\Frontend\PhpFrontend; |
38 | 36 | use TYPO3\CMS\Core\Package\PackageManager; |
39 | 37 | use TYPO3\CMS\Core\Resource\FileType; |
40 | | -use TYPO3\CMS\Core\Utility\GeneralUtility; |
41 | 38 |
|
42 | 39 | /** |
43 | 40 | * Main bootstrap loader for Content Blocks. This class finds registered |
@@ -79,6 +76,7 @@ public function __construct( |
79 | 76 | protected readonly BasicsLoader $basicsLoader, |
80 | 77 | protected readonly PackageManager $packageManager, |
81 | 78 | protected readonly IconProcessor $iconProcessor, |
| 79 | + protected readonly AssetPublisher $assetPublisher, |
82 | 80 | ) {} |
83 | 81 |
|
84 | 82 | public function load(): ContentBlockRegistry |
@@ -123,7 +121,7 @@ public function loadUncached(): ContentBlockRegistry |
123 | 121 | usort($loadedContentBlocks, $sortByPriority); |
124 | 122 | $contentBlockRegistry = $this->fillContentBlockRegistry($loadedContentBlocks); |
125 | 123 |
|
126 | | - $this->publishAssets($loadedContentBlocks); |
| 124 | + $this->assetPublisher->publishAssets($loadedContentBlocks); |
127 | 125 | $this->iconProcessor->process(); |
128 | 126 |
|
129 | 127 | return $contentBlockRegistry; |
@@ -317,44 +315,6 @@ protected function createPageIcon( |
317 | 315 | return $pageIcon; |
318 | 316 | } |
319 | 317 |
|
320 | | - /** |
321 | | - * @param LoadedContentBlock[] $loadedContentBlocks |
322 | | - */ |
323 | | - protected function publishAssets(array $loadedContentBlocks): void |
324 | | - { |
325 | | - $fileSystem = new Filesystem(); |
326 | | - foreach ($loadedContentBlocks as $loadedContentBlock) { |
327 | | - $hostExtension = $loadedContentBlock->getHostExtension(); |
328 | | - $contentBlockExtPublicPath = $loadedContentBlock->getExtPath() . '/' . ContentBlockPathUtility::getAssetsFolder(); |
329 | | - $contentBlockAbsolutePublicPath = GeneralUtility::getFileAbsFileName($contentBlockExtPublicPath); |
330 | | - // If the Content Block does not have an Assets folder, nothing to publish here. |
331 | | - if (!file_exists($contentBlockAbsolutePublicPath)) { |
332 | | - continue; |
333 | | - } |
334 | | - $hostAbsolutePublicContentBlockBasePath = ContentBlockPathUtility::getHostAbsolutePublicContentBlockBasePath($hostExtension); |
335 | | - // Prevent symlinks from being added to git index. |
336 | | - $gitIgnorePath = $hostAbsolutePublicContentBlockBasePath . '/.gitignore'; |
337 | | - if (!file_exists($gitIgnorePath)) { |
338 | | - GeneralUtility::mkdir_deep($hostAbsolutePublicContentBlockBasePath); |
339 | | - file_put_contents($gitIgnorePath, '*'); |
340 | | - } |
341 | | - $hostAbsolutePublicContentBlockBasePathWithVendor = $hostAbsolutePublicContentBlockBasePath . '/' . $loadedContentBlock->getVendor(); |
342 | | - $contentBlockRelativePublicPath = $fileSystem->makePathRelative( |
343 | | - $contentBlockAbsolutePublicPath, |
344 | | - $hostAbsolutePublicContentBlockBasePathWithVendor |
345 | | - ); |
346 | | - $hostAbsolutePublicContentBlockPath = ContentBlockPathUtility::getHostAbsolutePublicContentBlockPath( |
347 | | - $hostExtension, |
348 | | - $loadedContentBlock->getName(), |
349 | | - ); |
350 | | - try { |
351 | | - $fileSystem->symlink($contentBlockRelativePublicPath, $hostAbsolutePublicContentBlockPath); |
352 | | - } catch (IOException) { |
353 | | - $fileSystem->mirror($contentBlockAbsolutePublicPath, $hostAbsolutePublicContentBlockPath); |
354 | | - } |
355 | | - } |
356 | | - } |
357 | | - |
358 | 318 | protected function getFromCache(): false|array |
359 | 319 | { |
360 | 320 | return $this->cache->require('ContentBlocks_Raw'); |
|
0 commit comments