Using the API¶
The main functionality of this extension is to provide a PHP API which allows to locate XML sitemaps for a given site and optional site language. Read more about how to use this API on this page.
- class EliasHaeussler\Typo3SitemapLocator\Sitemap\SitemapLocator¶
Service to locate XML sitemaps of a given site.
- locateBySite($site, $siteLanguage = null)¶
Locate XML sitemaps of the given site and site language.
- Parameters
$site (
TYPO3\CMS\Core\Site\Entity\Site
) -- The site whose XML sitemap path should be located.$siteLanguage (
TYPO3\CMS\Core\Site\Entity\SiteLanguage
) -- An optional site language to include while locating the XML sitemap path.
- Returns
An array of instances of
EliasHaeussler\Typo3SitemapLocator\Domain\Model\Sitemap
.
- locateAllBySite($site)¶
Locate XML sitemaps of the given site and all their available languages.
- Parameters
$site (
TYPO3\CMS\Core\Site\Entity\Site
) -- The site whose XML sitemap path should be located.
- Returns
An array of instances of
EliasHaeussler\Typo3SitemapLocator\Domain\Model\Sitemap
, indexed by the site language id.
- isValidSitemap($sitemap)¶
Check whether the given sitemap actually exists.
- Parameters
$sitemap (
EliasHaeussler\Typo3SitemapLocator\Domain\Model\Sitemap
) -- The XML sitemap to check for existence
- Return type
bool
Example¶
use EliasHaeussler\Typo3SitemapLocator;
use TYPO3\CMS\Core;
$sitemapLocator = Core\Utility\GeneralUtility::makeInstance(Typo3SitemapLocator\Sitemap\SitemapLocator::class);
$siteFinder = Core\Utility\GeneralUtility::makeInstance(Core\Site\SiteFinder::class);
$sitemaps = [];
// Fetch all available sites
$sites = $siteFinder->getAllSites();
// Locate XML sitemaps of each site
foreach ($sites as $site) {
$sitemaps[$site->getIdentifier()] = $sitemapLocator->locateBySite($site);
}