PluginProbe
404 Solution / trunk
404 Solution vtrunk
4.3.5 4.3.4 4.3.3 4.3.2 4.3.1 4.3.0 4.2.0 4.1.19 4.1.18 4.1.17 4.1.16 4.1.15 4.1.13 4.1.12 4.1.11 4.1.10 4.1.9 4.1.8 4.1.7 4.1.6 4.1.5 4.1.4 4.1.3 trunk 2.30.0 All 109 releases
404-solution / includes / repositories / ContentRepository.php

ContentRepository.php in 404 Solution trunk, at includes/repositories/ContentRepository.php

164 lines 6.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 if (!defined('ABSPATH')) {
4 exit;
5 }
6
7 require_once __DIR__ . '/ContentRepositoryInterface.php';
8 require_once __DIR__ . '/PublishedContentRepository.php';
9 require_once __DIR__ . '/PermalinkCacheRepository.php';
10 require_once __DIR__ . '/SpellingCacheRepository.php';
11 require_once __DIR__ . '/OldSlugRepository.php';
12
13 /**
14 * Stable facade for published-content, cache, and old-slug repository operations.
15 *
16 * The legacy public contract remains here so existing callers can keep one
17 * injection point while the data-access responsibilities live in focused
18 * repositories.
19 */
20 class ABJ_404_Solution_ContentRepository implements ABJ_404_Solution_ContentRepositoryInterface {
21
22 /** @var ABJ_404_Solution_PublishedContentRepository */
23 private $publishedContentRepository;
24
25 /** @var ABJ_404_Solution_PermalinkCacheRepository */
26 private $permalinkCacheRepository;
27
28 /** @var ABJ_404_Solution_SpellingCacheRepository */
29 private $spellingCacheRepository;
30
31 /** @var ABJ_404_Solution_OldSlugRepository */
32 private $oldSlugRepository;
33
34 /**
35 * @param ABJ_404_Solution_DatabaseCore $dbCore
36 * @param ABJ_404_Solution_Functions|null $functions
37 * @param ABJ_404_Solution_Logging|null $logging
38 * @param mixed $optionsProvider Object exposing getOptions(): array. Defaults to options_repository service.
39 * @param ABJ_404_Solution_DatabaseErrorClassifier|null $errorClassifier
40 * @param ABJ_404_Solution_DatabaseCollationHelper|null $collationHelper
41 * @param ABJ_404_Solution_PublishedContentRepository|null $publishedContentRepository
42 * @param ABJ_404_Solution_PermalinkCacheRepository|null $permalinkCacheRepository
43 * @param ABJ_404_Solution_SpellingCacheRepository|null $spellingCacheRepository
44 * @param ABJ_404_Solution_OldSlugRepository|null $oldSlugRepository
45 */
46 public function __construct(
47 ABJ_404_Solution_DatabaseCore $dbCore,
48 $functions = null,
49 $logging = null,
50 $optionsProvider = null,
51 $errorClassifier = null,
52 $collationHelper = null,
53 $publishedContentRepository = null,
54 $permalinkCacheRepository = null,
55 $spellingCacheRepository = null,
56 $oldSlugRepository = null
57 ) {
58 $f = $functions !== null ? $functions : abj_service('functions');
59 $logger = $logging !== null ? $logging : abj_service('logging');
60 $resolvedErrorClassifier = $errorClassifier !== null ? $errorClassifier : $dbCore->errorClassifier();
61 $resolvedCollationHelper = $collationHelper !== null ? $collationHelper : $dbCore->collationHelper();
62
63 $this->publishedContentRepository = $publishedContentRepository !== null
64 ? $publishedContentRepository
65 : new ABJ_404_Solution_PublishedContentRepository(
66 $dbCore,
67 $f,
68 $logger,
69 $optionsProvider,
70 $resolvedErrorClassifier,
71 $resolvedCollationHelper
72 );
73 $this->permalinkCacheRepository = $permalinkCacheRepository !== null
74 ? $permalinkCacheRepository
75 : new ABJ_404_Solution_PermalinkCacheRepository($dbCore);
76 $this->spellingCacheRepository = $spellingCacheRepository !== null
77 ? $spellingCacheRepository
78 : new ABJ_404_Solution_SpellingCacheRepository($dbCore, $f);
79 $this->oldSlugRepository = $oldSlugRepository !== null
80 ? $oldSlugRepository
81 : new ABJ_404_Solution_OldSlugRepository($dbCore, $f);
82 }
83
84 /** @inheritDoc */
85 public function getPublishedPagesAndPostsIDs(array $criteria = array()) {
86 return $this->publishedContentRepository->getPublishedPagesAndPostsIDs($criteria);
87 }
88
89 /** @inheritDoc */
90 public function getPublishedTags($slug = null, $limit = null) {
91 return $this->publishedContentRepository->getPublishedTags($slug, $limit);
92 }
93
94 /** @inheritDoc */
95 public function addURLToTermsRows($rows) {
96 return $this->publishedContentRepository->addURLToTermsRows($rows);
97 }
98
99 /** @inheritDoc */
100 public function getPublishedCategories($term_id = null, $slug = null, $limit = null) {
101 return $this->publishedContentRepository->getPublishedCategories($term_id, $slug, $limit);
102 }
103
104 /** @inheritDoc */
105 public function truncatePermalinkCacheTable(): void {
106 $this->permalinkCacheRepository->truncatePermalinkCacheTable();
107 }
108
109 /** @inheritDoc */
110 public function removeFromPermalinkCache(int $post_id): void {
111 $this->permalinkCacheRepository->removeFromPermalinkCache($post_id);
112 }
113
114 /** @inheritDoc */
115 public function getPermalinkFromCache($id) {
116 return $this->permalinkCacheRepository->getPermalinkFromCache($id);
117 }
118
119 /** @inheritDoc */
120 public function getPermalinksByIds(array $ids) {
121 return $this->permalinkCacheRepository->getPermalinksByIds($ids);
122 }
123
124 /** @inheritDoc */
125 public function getPermalinkEtcFromCache($id) {
126 return $this->permalinkCacheRepository->getPermalinkEtcFromCache($id);
127 }
128
129 /** @inheritDoc */
130 public function updatePermalinkCache() {
131 return $this->permalinkCacheRepository->updatePermalinkCache();
132 }
133
134 /** @inheritDoc */
135 public function updatePermalinkCacheParentPages() {
136 return $this->permalinkCacheRepository->updatePermalinkCacheParentPages();
137 }
138
139 /** @inheritDoc */
140 public function getPermalinkCacheCount(): int {
141 return $this->permalinkCacheRepository->getPermalinkCacheCount();
142 }
143
144 /** @inheritDoc */
145 public function storeSpellingPermalinksToCache(string $requestedURLRaw, $returnValue): void {
146 $this->spellingCacheRepository->storeSpellingPermalinksToCache($requestedURLRaw, $returnValue);
147 }
148
149 /** @inheritDoc */
150 public function getSpellingPermalinksFromCache(string $requestedURLRaw) {
151 return $this->spellingCacheRepository->getSpellingPermalinksFromCache($requestedURLRaw);
152 }
153
154 /** @inheritDoc */
155 public function deleteSpellingCache(): void {
156 $this->spellingCacheRepository->deleteSpellingCache();
157 }
158
159 /** @inheritDoc */
160 public function getOldSlug($post_id) {
161 return $this->oldSlugRepository->getOldSlug($post_id);
162 }
163 }
164