‪TYPO3CMS  ‪main
FileMetadataOverlayAspect.php
Go to the documentation of this file.
1 <?php
2 
3 declare(strict_types=1);
4 
5 /*
6  * This file is part of the TYPO3 CMS project.
7  *
8  * It is free software; you can redistribute it and/or modify it under
9  * the terms of the GNU General Public License, either version 2
10  * of the License, or any later version.
11  *
12  * For the full copyright and license information, please read the
13  * LICENSE.txt file that was distributed with this source code.
14  *
15  * The TYPO3 project - inspiring people to share!
16  */
17 
19 
20 use Psr\Http\Message\ServerRequestInterface;
26 
36 {
40  #[AsEventListener('typo3-frontend/overlay')]
42  {
43  // Should only be in Frontend, but not in eID context
44  if (!(‪$GLOBALS['TYPO3_REQUEST'] ?? null) instanceof ServerRequestInterface
45  || !‪ApplicationType::fromRequest(‪$GLOBALS['TYPO3_REQUEST'])->isFrontend()
46  || isset($_REQUEST['eID'])
47  ) {
48  return;
49  }
50  $overlaidMetaData = $event->‪getRecord();
51  $pageRepository = GeneralUtility::makeInstance(PageRepository::class);
52  $pageRepository->versionOL('sys_file_metadata', $overlaidMetaData);
53  $overlaidMetaData = $pageRepository
54  ->getLanguageOverlay(
55  'sys_file_metadata',
56  $overlaidMetaData
57  );
58  if ($overlaidMetaData !== null) {
59  $event->‪setRecord($overlaidMetaData);
60  }
61  }
62 }
‪TYPO3\CMS\Core\Attribute\AsEventListener
Definition: AsEventListener.php:25
‪TYPO3\CMS\Frontend\Aspect\FileMetadataOverlayAspect\languageAndWorkspaceOverlay
‪languageAndWorkspaceOverlay(EnrichFileMetaDataEvent $event)
Definition: FileMetadataOverlayAspect.php:41
‪TYPO3\CMS\Frontend\Aspect\FileMetadataOverlayAspect
Definition: FileMetadataOverlayAspect.php:36
‪TYPO3\CMS\Core\Resource\Event\EnrichFileMetaDataEvent
Definition: EnrichFileMetaDataEvent.php:26
‪TYPO3\CMS\Core\Resource\Event\EnrichFileMetaDataEvent\setRecord
‪setRecord(array $record)
Definition: EnrichFileMetaDataEvent.php:44
‪$GLOBALS
‪$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['adminpanel']['modules']
Definition: ext_localconf.php:25
‪TYPO3\CMS\Core\Http\fromRequest
‪@ fromRequest
Definition: ApplicationType.php:66
‪TYPO3\CMS\Core\Domain\Repository\PageRepository
Definition: PageRepository.php:69
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:52
‪TYPO3\CMS\Core\Resource\Event\EnrichFileMetaDataEvent\getRecord
‪getRecord()
Definition: EnrichFileMetaDataEvent.php:39
‪TYPO3\CMS\Core\Http\ApplicationType
‪ApplicationType
Definition: ApplicationType.php:55
‪TYPO3\CMS\Frontend\Aspect
Definition: FileMetadataOverlayAspect.php:18