[TASK] Add pageId to getBackendLayout() method 85/25085/2
authorGeorg Ringer <georg.ringer@gmail.com>
Thu, 31 Oct 2013 08:48:36 +0000 (09:48 +0100)
committerGeorg Ringer <georg.ringer@gmail.com>
Thu, 7 Nov 2013 16:13:05 +0000 (17:13 +0100)
The new BackendLayout providers should be able to get the page id.
Otherwise it might be hard for some cases to return the correct layout.
E.g if working with TsConfig, a page id is needed to get the correct
tsconfig

Change-Id: If455f951b735c3af406cd9c96f057dad1eebb2bc
Resolves: #53244
Releases: 6.2
Reviewed-on: https://review.typo3.org/25085
Reviewed-by: Wouter Wolters
Reviewed-by: Jo Hasenau
Reviewed-by: Philipp Gampe
Tested-by: Philipp Gampe
Reviewed-by: Georg Ringer
Tested-by: Georg Ringer
typo3/sysext/backend/Classes/View/BackendLayout/DataProviderCollection.php
typo3/sysext/backend/Classes/View/BackendLayout/DataProviderInterface.php
typo3/sysext/backend/Classes/View/BackendLayout/DefaultDataProvider.php
typo3/sysext/backend/Classes/View/BackendLayoutView.php
typo3/sysext/backend/Tests/Unit/View/BackendLayout/DataProviderCollectionTest.php

index 7f93dc8..669de42 100644 (file)
@@ -105,9 +105,10 @@ class DataProviderCollection implements \TYPO3\CMS\Core\SingletonInterface {
         * the accordant backend layout.
         *
         * @param string $combinedIdentifier
+        * @param integer $pageId
         * @return NULL|BackendLayout
         */
-       public function getBackendLayout($combinedIdentifier) {
+       public function getBackendLayout($combinedIdentifier, $pageId) {
                $backendLayout = NULL;
 
                if (strpos($combinedIdentifier, '__') === FALSE) {
@@ -118,7 +119,7 @@ class DataProviderCollection implements \TYPO3\CMS\Core\SingletonInterface {
                }
 
                if (isset($this->dataProviders[$dataProviderIdentifier])) {
-                       $backendLayout = $this->dataProviders[$dataProviderIdentifier]->getBackendLayout($backendLayoutIdentifier);
+                       $backendLayout = $this->dataProviders[$dataProviderIdentifier]->getBackendLayout($backendLayoutIdentifier, $pageId);
                }
 
                return $backendLayout;
index cd8cf3e..638afc8 100644 (file)
@@ -48,8 +48,9 @@ interface DataProviderInterface {
         * Gets a backend layout by (regular) identifier.
         *
         * @param string $identifier
+        * @param integer $pageId
         * @return NULL|BackendLayout
         */
-       public function getBackendLayout($identifier);
+       public function getBackendLayout($identifier, $pageId);
 
 }
\ No newline at end of file
index 8bb3924..0f3f246 100644 (file)
@@ -63,9 +63,10 @@ class DefaultDataProvider implements DataProviderInterface {
         * Gets a backend layout by (regular) identifier.
         *
         * @param string $identifier
+        * @param integer $pageId
         * @return NULL|BackendLayout
         */
-       public function getBackendLayout($identifier) {
+       public function getBackendLayout($identifier, $pageId) {
                $backendLayout = NULL;
 
                if ((string) $identifier === 'default') {
@@ -205,4 +206,4 @@ class DefaultDataProvider implements DataProviderInterface {
                return $GLOBALS['TYPO3_DB'];
        }
 
-}
\ No newline at end of file
+}
index a6a0bab..9669df6 100644 (file)
@@ -309,7 +309,7 @@ class BackendLayoutView implements \TYPO3\CMS\Core\SingletonInterface {
                        $selectedCombinedIdentifier = 'default';
                }
 
-               $backendLayout = $this->getDataProviderCollection()->getBackendLayout($selectedCombinedIdentifier);
+               $backendLayout = $this->getDataProviderCollection()->getBackendLayout($selectedCombinedIdentifier, $pageId);
 
                if (!empty($backendLayout)) {
                        /** @var $parser \TYPO3\CMS\Core\TypoScript\Parser\TypoScriptParser */
index 2203aa1..10a42c5 100644 (file)
@@ -87,7 +87,7 @@ class DataProviderCollectionTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
                $dataProviderMock->expects($this->once())->method('getBackendLayout')->will($this->returnValue($backendLayoutMock));
 
                $this->dataProviderCollection->add('default', $dataProviderMock);
-               $providedBackendLayout = $this->dataProviderCollection->getBackendLayout($backendLayoutIdentifier);
+               $providedBackendLayout = $this->dataProviderCollection->getBackendLayout($backendLayoutIdentifier, 123);
 
                $this->assertNotNull($providedBackendLayout);
                $this->assertEquals($backendLayoutIdentifier, $providedBackendLayout->getIdentifier());
@@ -106,7 +106,7 @@ class DataProviderCollectionTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
                $dataProviderMock->expects($this->once())->method('getBackendLayout')->will($this->returnValue($backendLayoutMock));
 
                $this->dataProviderCollection->add($dataProviderIdentifier, $dataProviderMock);
-               $providedBackendLayout = $this->dataProviderCollection->getBackendLayout($dataProviderIdentifier . '__' . $backendLayoutIdentifier);
+               $providedBackendLayout = $this->dataProviderCollection->getBackendLayout($dataProviderIdentifier . '__' . $backendLayoutIdentifier, 123);
 
                $this->assertNotNull($providedBackendLayout);
                $this->assertEquals($backendLayoutIdentifier, $providedBackendLayout->getIdentifier());