[TASK] Decouple t3editor hooks from DocumentTemplate 18/43818/4
authorMathias Schreiber <mathias.schreiber@wmdb.de>
Mon, 5 Oct 2015 13:51:34 +0000 (15:51 +0200)
committerAndreas Fernandez <typo3@scripting-base.de>
Mon, 5 Oct 2015 16:06:36 +0000 (18:06 +0200)
Releases: master
Resolves: #70387
Change-Id: I5d5c21d10982d3be833948977464a9c9eab1a51e
Reviewed-on: http://review.typo3.org/43818
Reviewed-by: Nicole Cordes <typo3@cordes.co>
Tested-by: Nicole Cordes <typo3@cordes.co>
Reviewed-by: Andreas Fernandez <typo3@scripting-base.de>
Tested-by: Andreas Fernandez <typo3@scripting-base.de>
typo3/sysext/t3editor/Classes/T3editor.php

index 441701a..11a3903 100644 (file)
@@ -17,6 +17,7 @@ namespace TYPO3\CMS\T3editor;
 use Psr\Http\Message\ResponseInterface;
 use Psr\Http\Message\ServerRequestInterface;
 use TYPO3\CMS\Core\Page\PageRenderer;
+use TYPO3\CMS\Core\Utility\ExtensionManagementUtility;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
 
 /**
@@ -177,34 +178,21 @@ class T3editor implements \TYPO3\CMS\Core\SingletonInterface {
        /**
         * Retrieves JavaScript code (header part) for editor
         *
-        * @param \TYPO3\CMS\Backend\Template\DocumentTemplate $doc
         * @return string
         */
-       public function getJavascriptCode($doc) {
+       public function getJavascriptCode() {
                /** @var $pageRenderer \TYPO3\CMS\Core\Page\PageRenderer */
                $pageRenderer = $this->getPageRenderer();
-
-               $doc->addStyleSheet('t3editor', $this->relExtPath . 'Resources/Public/Css/t3editor.css');
-
+               $pageRenderer->addCssFile($this->relExtPath . 'Resources/Public/Css/t3editor.css');
                // Include editor-js-lib
-               $doc->loadJavascriptLib($this->codemirrorPath . 'codemirror.js');
-               $this->loadTypoScriptCodeCompletion($doc);
-               $pageRenderer->loadRequireJsModule('TYPO3/CMS/T3editor/T3editor');
-               return '';
-       }
-
-       /**
-        * Load additional code completion for TypoScript
-        *
-        * @param \TYPO3\CMS\Backend\Template\DocumentTemplate $doc
-        */
-       protected function loadTypoScriptCodeCompletion($doc) {
+               $pageRenderer->addJsLibrary('codemirror', $this->codemirrorPath . 'codemirror.js');
                if ($this->mode === self::MODE_TYPOSCRIPT) {
-                       $pageRenderer = $doc->getPageRenderer();
                        foreach ($this->codeCompletionComponents as $codeCompletionComponent) {
                                $pageRenderer->loadRequireJsModule('TYPO3/CMS/T3editor/Plugins/CodeCompletion/' . $codeCompletionComponent);
                        }
                }
+               $pageRenderer->loadRequireJsModule('TYPO3/CMS/T3editor/T3editor');
+               return '';
        }
 
        /**