| @@ -26,9 +26,16 @@ | ||
| 26 | 26 | private Cache $cache |
| 27 | 27 | ) { |
| 28 | 28 | } |
| 29 | 29 | |
| 30 | - private function processTreeMapElements(array &$map, ?array $subMap = null, array &$processed = []): array | |
| 30 | + /** | |
| 31 | + * Resolves all tree map elements | |
| 32 | + * @param array $map | |
| 33 | + * @param array|null $subMap | |
| 34 | + * @param array $processed | |
| 35 | + * @return array | |
| 36 | + */ | |
| 37 | + private function processTreeMapElements(array &$map, array $subMap = null, array &$processed = []): array | |
| 31 | 38 | { |
| 32 | 39 | $processMap = ($subMap === null) ? $map : $subMap; |
| 33 | 40 | |
| 34 | 41 | foreach ($processMap as $id => $subIds) { |
| @@ -61,10 +68,11 @@ | ||
| 61 | 68 | $treeMap[self::TREE_MAP_PARENTS][$generalType][$result->id][$result->parentId] = $result->type; |
| 62 | 69 | $treeMap[self::TREE_MAP_PARENTS][$result->type][$result->id][$result->parentId] = $result->type; |
| 63 | 70 | } |
| 64 | 71 | |
| 65 | - foreach ($treeMap as $mapType => $mapsByObjectType) { | |
| 66 | - foreach ($mapsByObjectType as $objectType => $map) { | |
| 72 | + //Process elements | |
| 73 | + foreach ($treeMap as $mapType => $mayTypeMap) { | |
| 74 | + foreach ($mayTypeMap as $objectType => $map) { | |
| 67 | 75 | $treeMap[$mapType][(string) $objectType] = $this->processTreeMapElements($map); |
| 68 | 76 | } |
| 69 | 77 | } |
| 70 | 78 | |
| @@ -79,12 +87,13 @@ | ||
| 79 | 87 | $map = $this->getTreeMap($query, $generalType); |
| 80 | 88 | $this->cache->add($cacheKey, $map); |
| 81 | 89 | } |
| 82 | 90 | |
| 91 | + | |
| 83 | 92 | return $map; |
| 84 | 93 | } |
| 85 | 94 | |
| 86 | - public function getPostTreeMap(): array | |
| 95 | + public function getPostTreeMap(): ?array | |
| 87 | 96 | { |
| 88 | 97 | if ($this->postTreeMap === null) { |
| 89 | 98 | $query = "SELECT ID AS id, post_parent AS parentId, post_type AS type |
| 90 | 99 | FROM {$this->database->getPostsTable()} |
| @@ -99,9 +108,9 @@ | ||
| 99 | 108 | |
| 100 | 109 | return $this->postTreeMap; |
| 101 | 110 | } |
| 102 | 111 | |
| 103 | - public function getTermTreeMap(): array | |
| 112 | + public function getTermTreeMap(): ?array | |
| 104 | 113 | { |
| 105 | 114 | if ($this->termTreeMap === null) { |
| 106 | 115 | $query = "SELECT term_id AS id, parent AS parentId, taxonomy AS type |
| 107 | 116 | FROM {$this->database->getTermTaxonomyTable()} |
| @@ -134,9 +143,9 @@ | ||
| 134 | 143 | |
| 135 | 144 | return $map; |
| 136 | 145 | } |
| 137 | 146 | |
| 138 | - public function getTermPostMap(): array | |
| 147 | + public function getTermPostMap(): ?array | |
| 139 | 148 | { |
| 140 | 149 | if ($this->termPostMap === null) { |
| 141 | 150 | $select = " |
| 142 | 151 | SELECT tr.object_id AS objectId, tt.term_id AS parentId, p.post_type AS type |
| @@ -151,9 +160,9 @@ | ||
| 151 | 160 | |
| 152 | 161 | return $this->termPostMap; |
| 153 | 162 | } |
| 154 | 163 | |
| 155 | - public function getPostTermMap(): array | |
| 164 | + public function getPostTermMap(): ?array | |
| 156 | 165 | { |
| 157 | 166 | if ($this->postTermMap === null) { |
| 158 | 167 | $select = " |
| 159 | 168 | SELECT tr.object_id AS parentId, tt.term_id AS objectId, tt.taxonomy AS type |