[TASK] Streamline phpdoc annotations in EXT:extbase
[Packages/TYPO3.CMS.git] / typo3 / sysext / extbase / Classes / Domain / Model / FileReference.php
1 <?php
2 namespace TYPO3\CMS\Extbase\Domain\Model;
3
4 /*
5 * This file is part of the TYPO3 CMS project.
6 *
7 * It is free software; you can redistribute it and/or modify it under
8 * the terms of the GNU General Public License, either version 2
9 * of the License, or any later version.
10 *
11 * For the full copyright and license information, please read the
12 * LICENSE.txt file that was distributed with this source code.
13 *
14 * The TYPO3 project - inspiring people to share!
15 */
16
17 use TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface;
18
19 /**
20 * A file reference object (File Abstraction Layer)
21 *
22 * @internal experimental! This class is experimental and subject to change!
23 */
24 class FileReference extends \TYPO3\CMS\Extbase\Domain\Model\AbstractFileFolder
25 {
26 /**
27 * Uid of the referenced sys_file. Needed for extbase to serialize the
28 * reference correctly.
29 *
30 * @var int
31 */
32 protected $uidLocal;
33
34 /**
35 * @var \TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface
36 */
37 protected $configurationManager;
38
39 /**
40 * @param \TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface $configurationManager
41 */
42 public function injectConfigurationManager(ConfigurationManagerInterface $configurationManager)
43 {
44 $this->configurationManager = $configurationManager;
45 }
46
47 /**
48 * @param \TYPO3\CMS\Core\Resource\ResourceInterface $originalResource
49 */
50 public function setOriginalResource(\TYPO3\CMS\Core\Resource\ResourceInterface $originalResource)
51 {
52 $this->originalResource = $originalResource;
53 $this->uidLocal = (int)$originalResource->getOriginalFile()->getUid();
54 }
55
56 /**
57 * @return \TYPO3\CMS\Core\Resource\FileReference
58 */
59 public function getOriginalResource()
60 {
61 if ($this->originalResource === null) {
62 $uid = $this->getUid();
63 if ($this->configurationManager->isFeatureEnabled('consistentTranslationOverlayHandling')) {
64 $uid = $this->_localizedUid;
65 }
66 $this->originalResource = \TYPO3\CMS\Core\Resource\ResourceFactory::getInstance()->getFileReferenceObject($uid);
67 }
68
69 return $this->originalResource;
70 }
71 }