Returns main language ID of the Content on the Location with given $locationId.
abstract public getLocationContentMainLanguageId ( integer $locationId ) : integer | ||
$locationId | integer | |
return | integer |
public function locationSwapped($location1Id, $location1ParentId, $location2Id, $location2ParentId) { $location1Entries = $this->gateway->loadLocationEntries($location1Id); $location2Entries = $this->gateway->loadLocationEntries($location2Id); $location1MainLanguageId = $this->gateway->getLocationContentMainLanguageId($location1Id); $location2MainLanguageId = $this->gateway->getLocationContentMainLanguageId($location2Id); // Load autogenerated entries to find alias ID $autoLocation1 = $this->gateway->loadAutogeneratedEntry("eznode:{$location1Id}"); $autoLocation2 = $this->gateway->loadAutogeneratedEntry("eznode:{$location2Id}"); // Historize everything first to avoid name conflicts in case swapped Locations are siblings $this->historizeBeforeSwap($location1Entries, $location2Entries); foreach ($location2Entries as $row) { $alwaysAvailable = (bool) ($row['lang_mask'] & 1); $languageIds = $this->extractLanguageIdsFromMask($row['lang_mask']); foreach ($languageIds as $languageId) { $isMainLanguage = $languageId == $location2MainLanguageId; $this->internalPublishUrlAliasForLocation($location1Id, $location1ParentId, $row['text'], $languageId, $isMainLanguage && $alwaysAvailable, $isMainLanguage, $autoLocation1['id']); } } foreach ($location1Entries as $row) { $alwaysAvailable = (bool) ($row['lang_mask'] & 1); $languageIds = $this->extractLanguageIdsFromMask($row['lang_mask']); foreach ($languageIds as $languageId) { $isMainLanguage = $languageId == $location1MainLanguageId; $this->internalPublishUrlAliasForLocation($location2Id, $location2ParentId, $row['text'], $languageId, $isMainLanguage && $alwaysAvailable, $isMainLanguage, $autoLocation2['id']); } } }
public function getLocationContentMainLanguageId($locationId) { try { return $this->innerGateway->getLocationContentMainLanguageId($locationId); } catch (DBALException $e) { throw new \RuntimeException('Database error', 0, $e); } catch (PDOException $e) { throw new \RuntimeException('Database error', 0, $e); } }