[TASK] Remove compat layer for new 6.0 classes
[Packages/TYPO3.CMS.git] / typo3 / sysext / core / Classes / Resource / FileCollectionRepository.php
1 <?php
2 namespace TYPO3\CMS\Core\Resource;
3
4 /***************************************************************
5 * Copyright notice
6 *
7 * (c) 2011-2012 Andreas Wolf <andreas.wolf@ikt-werk.de>
8 * All rights reserved
9 *
10 * This script is part of the TYPO3 project. The TYPO3 project is
11 * free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
15 *
16 * The GNU General Public License can be found at
17 * http://www.gnu.org/copyleft/gpl.html.
18 * A copy is found in the textfile GPL.txt and important notices to the license
19 * from the author is found in LICENSE.txt distributed with these scripts.
20 *
21 *
22 * This script is distributed in the hope that it will be useful,
23 * but WITHOUT ANY WARRANTY; without even the implied warranty of
24 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25 * GNU General Public License for more details.
26 *
27 * This copyright notice MUST APPEAR in all copies of the script!
28 ***************************************************************/
29 /**
30 * Repository for accessing the collections stored in the database
31 *
32 * @author Andreas Wolf <andreas.wolf@ikt-werk.de>
33 * @author Ingmar Schlecht <ingmar@typo3.org>
34 * @package TYPO3
35 * @subpackage t3lib
36 */
37 class FileCollectionRepository extends \TYPO3\CMS\Core\Collection\RecordCollectionRepository {
38
39 /**
40 * @var string
41 */
42 protected $table = 'sys_file_collection';
43
44 /**
45 * @var string
46 */
47 protected $typeField = 'type';
48
49 /**
50 * Finds a record collection by uid.
51 *
52 * @todo the parent function throws already an exception if not found
53 * @param integer $uid The uid to be looked up
54 * @return NULL|\TYPO3\CMS\Core\Resource\Collection\AbstractFileCollection
55 * @throws \RuntimeException
56 */
57 public function findByUid($uid) {
58 $object = parent::findByUid($uid);
59 if ($object === NULL) {
60 throw new \RuntimeException(((('Could not find row with uid "' . $uid) . '" in table "') . $this->table) . '"', 1314354065);
61 }
62 return $object;
63 }
64
65 /**
66 * Creates a record collection domain object.
67 *
68 * @param $record Database record to be reconsituted
69 * @return \TYPO3\CMS\Core\Resource\Collection\AbstractFileCollection
70 */
71 protected function createDomainObject(array $record) {
72 return $this->getFileFactory()->createCollectionObject($record);
73 }
74
75 /**
76 * Gets the file factory.
77 *
78 * @return \TYPO3\CMS\Core\Resource\ResourceFactory
79 */
80 protected function getFileFactory() {
81 return \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Resource\\ResourceFactory');
82 }
83
84 }
85
86
87 ?>