| @@ 57-83 (lines=27) @@ | ||
| 54 | /** |
|
| 55 | * {@inheritdoc} |
|
| 56 | */ |
|
| 57 | public function loadLocationsByContent($contentId, $rootLocationId = null) |
|
| 58 | { |
|
| 59 | if ($rootLocationId) { |
|
| 60 | $cache = $this->cache->getItem('content', 'locations', $contentId, 'root', $rootLocationId); |
|
| 61 | } else { |
|
| 62 | $cache = $this->cache->getItem('content', 'locations', $contentId); |
|
| 63 | } |
|
| 64 | $locationIds = $cache->get(); |
|
| 65 | if ($cache->isMiss()) { |
|
| 66 | $this->logger->logCall(__METHOD__, array('content' => $contentId, 'root' => $rootLocationId)); |
|
| 67 | $locations = $this->persistenceHandler->locationHandler()->loadLocationsByContent($contentId, $rootLocationId); |
|
| 68 | ||
| 69 | $locationIds = array(); |
|
| 70 | foreach ($locations as $location) { |
|
| 71 | $locationIds[] = $location->id; |
|
| 72 | } |
|
| 73 | ||
| 74 | $cache->set($locationIds)->save(); |
|
| 75 | } else { |
|
| 76 | $locations = array(); |
|
| 77 | foreach ($locationIds as $locationId) { |
|
| 78 | $locations[] = $this->load($locationId); |
|
| 79 | } |
|
| 80 | } |
|
| 81 | ||
| 82 | return $locations; |
|
| 83 | } |
|
| 84 | ||
| 85 | /** |
|
| 86 | * {@inheritdoc} |
|
| @@ 141-169 (lines=29) @@ | ||
| 138 | /** |
|
| 139 | * {@inheritdoc} |
|
| 140 | */ |
|
| 141 | public function listURLAliasesForLocation($locationId, $custom = false) |
|
| 142 | { |
|
| 143 | // Look for location to list of url alias id's cache |
|
| 144 | if ($custom) { |
|
| 145 | $cache = $this->cache->getItem('urlAlias', 'location', $locationId, 'custom'); |
|
| 146 | } else { |
|
| 147 | $cache = $this->cache->getItem('urlAlias', 'location', $locationId); |
|
| 148 | } |
|
| 149 | $urlAliasIds = $cache->get(); |
|
| 150 | if ($cache->isMiss()) { |
|
| 151 | $this->logger->logCall(__METHOD__, array('location' => $locationId, 'custom' => $custom)); |
|
| 152 | $urlAliases = $this->persistenceHandler->urlAliasHandler()->listURLAliasesForLocation($locationId, $custom); |
|
| 153 | ||
| 154 | $urlAliasIds = array(); |
|
| 155 | foreach ($urlAliases as $urlAlias) { |
|
| 156 | $urlAliasIds[] = $urlAlias->id; |
|
| 157 | } |
|
| 158 | ||
| 159 | $cache->set($urlAliasIds)->save(); |
|
| 160 | } else { |
|
| 161 | // Reuse loadUrlAlias for the url alias object cache |
|
| 162 | $urlAliases = array(); |
|
| 163 | foreach ($urlAliasIds as $urlAliasId) { |
|
| 164 | $urlAliases[] = $this->loadUrlAlias($urlAliasId); |
|
| 165 | } |
|
| 166 | } |
|
| 167 | ||
| 168 | return $urlAliases; |
|
| 169 | } |
|
| 170 | ||
| 171 | /** |
|
| 172 | * {@inheritdoc} |
|