5bd038b7d29919bf594c55d8ccab116c402e4494
[Packages/TYPO3.CMS.git] / typo3 / sysext / extensionmanager / Classes / Domain / Repository / RepositoryRepository.php
1 <?php
2 namespace TYPO3\CMS\Extensionmanager\Domain\Repository;
3
4 /***************************************************************
5 * Copyright notice
6 *
7 * (c) 2012-2013 Susanne Moog, <susanne.moog@typo3.org>
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 *
19 * This script is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
23 *
24 * This copyright notice MUST APPEAR in all copies of the script!
25 ***************************************************************/
26 /**
27 * A repository for extension repositories
28 *
29 * @author Susanne Moog <typo3@susannemoog.de>
30 */
31 class RepositoryRepository extends \TYPO3\CMS\Extbase\Persistence\Repository {
32
33 /**
34 * Do not include pid in queries
35 *
36 * @return void
37 */
38 public function initializeObject() {
39 /** @var $defaultQuerySettings \TYPO3\CMS\Extbase\Persistence\Generic\QuerySettingsInterface */
40 $defaultQuerySettings = $this->objectManager->get('TYPO3\\CMS\\Extbase\\Persistence\\Generic\\QuerySettingsInterface');
41 $defaultQuerySettings->setRespectStoragePage(FALSE);
42 $this->setDefaultQuerySettings($defaultQuerySettings);
43 }
44
45 /**
46 * Updates ExtCount and lastUpdated in Repository eg after import
47 *
48 * @param integer $extCount
49 * @param integer $uid
50 * @return void
51 */
52 public function updateRepositoryCount($extCount, $uid = 1) {
53 $repository = $this->findByUid($uid);
54
55 $repository->setLastUpdate(new \DateTime());
56 $repository->setExtensionCount((int)$extCount);
57
58 $this->update($repository);
59 }
60
61 /**
62 * Find main typo3.org repository
63 *
64 * @return \TYPO3\CMS\Extensionmanager\Domain\Model\Repository
65 */
66 public function findOneTypo3OrgRepository() {
67 $allRepositories = $this->findAll();
68 $typo3OrgRepository = NULL;
69 foreach ($allRepositories as $repository) {
70 /** @var $repository \TYPO3\CMS\Extensionmanager\Domain\Model\Repository */
71 if ($repository->getTitle() === 'TYPO3.org Main Repository') {
72 $typo3OrgRepository = $repository;
73 break;
74 }
75 }
76 return $typo3OrgRepository;
77 }
78 }