Commit c7bc41e3 authored by Tomas Norre Mikkelsen's avatar Tomas Norre Mikkelsen

Merge branch 'bugfix/use-assoc-array-for-documentation-json' into 'develop'

Fix documentation fetching and add fallback with old data

See merge request !424
parents dcbc72d2 9466f2f5
Pipeline #7331 passed with stages
in 5 minutes and 9 seconds
......@@ -43,7 +43,7 @@ class DocumentationService implements \TYPO3\CMS\Core\SingletonInterface
'pdf'
];
$documentationFile = PATH_site . $GLOBALS['TYPO3_CONF_VARS']['BE']['fileadminDir'] . 'currentdocumentationdata.json';
$this->docsInformation = json_decode(file_get_contents($documentationFile));
$this->docsInformation = json_decode(file_get_contents($documentationFile), true);
}
/**
......@@ -60,16 +60,19 @@ class DocumentationService implements \TYPO3\CMS\Core\SingletonInterface
if (empty($extensionKey) || empty($versionString)) {
throw new \Exception('Extension key and version string are required to build a documentation url');
}
$url = '';
$documentationLink = '';
$oldManualsInformation = json_decode(@file_get_contents(PATH_site . $GLOBALS['TYPO3_CONF_VARS']['BE']['fileadminDir'] . 'oldmanuals.json'), true);
$manualExists = isset($this->docsInformation->{$extensionKey}['docs'][$versionString]);
$documentationLink = null;
$url = null;
if ($manualExists) {
if (isset($this->docsInformation[$extensionKey]['docs'][$versionString])) {
// link to extension to get the latest manual
$url = $this->docsInformation->{$extensionKey}['docs'][$versionString]['url'];
// check if link is not broken
// need to remove the 200 response check due to change in header for docs.typo3.org
$url = $this->docsInformation[$extensionKey]['docs'][$versionString]['url'];
} elseif (isset($oldManualsInformation[$extensionKey])) {
$baseUrl = 'https://docs.typo3.org/typo3cms/extensions/';
$url = $baseUrl . $extensionKey . '/';
}
if ($url) {
$documentationLink = '<a href="' . $url . '">Extension Manual</a>';
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment