[FEATURE] Provide TSConfig to link checkers 99/26499/10
authorAlexander Stehlik <alexander.stehlik@gmail.com>
Wed, 19 Nov 2014 18:00:46 +0000 (19:00 +0100)
committerAnja Leichsenring <aleichsenring@ab-softlab.de>
Wed, 19 Nov 2014 18:19:19 +0000 (19:19 +0100)
The currently active TSConfig for the linkvalidator is passed
to the LinkAnalyser instance which makes it publicly available
for the link checkers.

Resolves: #54518
Releases: master
Change-Id: I59d1de5fb3f818d340f499260589edf9a45d3148
Reviewed-on: http://review.typo3.org/26499
Reviewed-by: Markus Klein <klein.t3@reelworx.at>
Tested-by: Markus Klein <klein.t3@reelworx.at>
Reviewed-by: Anja Leichsenring <aleichsenring@ab-softlab.de>
Tested-by: Anja Leichsenring <aleichsenring@ab-softlab.de>
typo3/sysext/core/Documentation/Changelog/master/Feature-54518-ProvideTsconfigToLinkCheckers.rst [new file with mode: 0644]
typo3/sysext/linkvalidator/Classes/LinkAnalyzer.php
typo3/sysext/linkvalidator/Classes/Report/LinkValidatorReport.php
typo3/sysext/linkvalidator/Classes/Task/ValidatorTask.php

diff --git a/typo3/sysext/core/Documentation/Changelog/master/Feature-54518-ProvideTsconfigToLinkCheckers.rst b/typo3/sysext/core/Documentation/Changelog/master/Feature-54518-ProvideTsconfigToLinkCheckers.rst
new file mode 100644 (file)
index 0000000..2cdfde3
--- /dev/null
@@ -0,0 +1,31 @@
+===================================================
+Feature: #54518 - Provide TSconfig to link checkers
+===================================================
+
+Description
+===========
+
+The active TSconfig of the linkvalidator is stored in the LinkAnalyser and made
+publicly available to the link checkers.
+
+The TSconfig is read either from the currently active TSconfig in the Backend
+when the linkvalidator is used in the info module or from the configuration
+provided in the linkvalidator scheduler task.
+
+This allows passing configuration to the different link checkers.
+
+
+Usage:
+
+.. code-block:: typoscript
+
+       # The configuration in mod.linkvalidator can be read by the link checkers.
+       mod.linkvalidator.mychecker.myvar = 1
+
+..
+
+Impact
+======
+
+The method signature of `\TYPO3\CMS\Linkvalidator::LinkAnalyser::init()` is changed. A new paramter is added
+for submitting the current TSconfig. This can break third party code that extends this method.
index b8fb804..ad43531 100644 (file)
@@ -88,6 +88,13 @@ class LinkAnalyzer {
        protected $pageWithAnchor = '';
 
        /**
+        * The currently active TSConfig. Will be passed to the init function.
+        *
+        * @var array
+        */
+       protected $tsConfig = array();
+
+       /**
         * Fill hookObjectsArr with different link types and possible XClasses.
         */
        public function __construct() {
@@ -105,11 +112,13 @@ class LinkAnalyzer {
         *
         * @param array $searchField List of fields in which to search for links
         * @param string $pid List of comma separated page uids in which to search for links
+        * @param array $tsConfig The currently active TSConfig.
         * @return void
         */
-       public function init(array $searchField, $pid) {
+       public function init(array $searchField, $pid, $tsConfig) {
                $this->searchFields = $searchField;
                $this->pidList = $pid;
+               $this->tsConfig = $tsConfig;
        }
 
        /**
@@ -251,6 +260,18 @@ class LinkAnalyzer {
        }
 
        /**
+        * Returns the TSConfig that was passed to the init() method.
+        *
+        * This can be used by link checkers that get a reference of this
+        * object passed to the checkLink() method.
+        *
+        * @return array
+        */
+       public function getTSConfig() {
+               return $this->tsConfig;
+       }
+
+       /**
         * Find all supported broken links for a specific link list
         *
         * @param array $resultArray findRef parsed records
index da92262..b5e82d1 100644 (file)
@@ -320,7 +320,7 @@ class LinkValidatorReport extends \TYPO3\CMS\Backend\Module\AbstractFunctionModu
                        if ($this->pObj->pageinfo['hidden'] == 0 || $this->modTS['checkhidden'] == 1) {
                                $pageList .= $this->pObj->id;
                        }
-                       $this->processor->init($searchFields, $pageList);
+                       $this->processor->init($searchFields, $pageList, $this->modTS);
                        // Check if button press
                        $update = GeneralUtility::_GP('updateLinkList');
                        if (!empty($update)) {
index d3c4d40..4c611d7 100644 (file)
@@ -298,7 +298,7 @@ class ValidatorTask extends \TYPO3\CMS\Scheduler\Task\AbstractTask {
                        }
                }
                if (!empty($pageIds)) {
-                       $processor->init($searchFields, $pageIds);
+                       $processor->init($searchFields, $pageIds, $modTs);
                        if (!empty($this->email)) {
                                $oldLinkCounts = $processor->getLinkCounts($page);
                                $this->oldTotalBrokenLink += $oldLinkCounts['brokenlinkCount'];