From 3e1fd7416f5a115ba6144c8d9bbe669ae39bf615 Mon Sep 17 00:00:00 2001 From: Oliver Klee Date: Mon, 28 May 2018 17:05:39 +0200 Subject: [PATCH] [FEATURE] Tea single view (#26) --- Classes/Controller/TeaController.php | 11 +++++++ Configuration/FlexForms/Plugin.xml | 4 +++ .../TCA/tx_tea_domain_model_product_tea.php | 9 +++++- Configuration/TypoScript/constants.txt | 3 +- Configuration/TypoScript/setup.txt | 2 +- Resources/Private/Language/de.locallang.xlf | 4 +++ Resources/Private/Language/locallang.xlf | 3 ++ Resources/Private/Templates/Tea/Index.html | 4 ++- Resources/Private/Templates/Tea/Show.html | 12 ++++++++ .../Controller/Fixtures/Database/pages.xml | 29 ++++++++++++++++++- .../Fixtures/Frontend/Basic.typoscript | 6 ++++ Tests/Unit/Controller/TeaControllerTest.php | 12 ++++++++ ext_localconf.php | 2 +- 13 files changed, 95 insertions(+), 6 deletions(-) create mode 100644 Resources/Private/Templates/Tea/Show.html diff --git a/Classes/Controller/TeaController.php b/Classes/Controller/TeaController.php index 13078f8..ef3b15f 100644 --- a/Classes/Controller/TeaController.php +++ b/Classes/Controller/TeaController.php @@ -2,6 +2,7 @@ declare(strict_types = 1); namespace OliverKlee\Tea\Controller; +use OliverKlee\Tea\Domain\Model\Product\Tea; use OliverKlee\Tea\Domain\Repository\Product\TeaRepository; use TYPO3\CMS\Extbase\Mvc\Controller\ActionController; @@ -34,4 +35,14 @@ class TeaController extends ActionController { $this->view->assign('teas', $this->teaRepository->findAll()); } + + /** + * @param Tea $tea + * + * @return void + */ + public function showAction(Tea $tea) + { + $this->view->assign('tea', $tea); + } } diff --git a/Configuration/FlexForms/Plugin.xml b/Configuration/FlexForms/Plugin.xml index 53f069d..a32f305 100644 --- a/Configuration/FlexForms/Plugin.xml +++ b/Configuration/FlexForms/Plugin.xml @@ -24,6 +24,10 @@ LLL:EXT:tea/Resources/Private/Language/locallang.xlf:plugin.tea.index Tea->index + + LLL:EXT:tea/Resources/Private/Language/locallang.xlf:plugin.tea.show + Tea->show + diff --git a/Configuration/TCA/tx_tea_domain_model_product_tea.php b/Configuration/TCA/tx_tea_domain_model_product_tea.php index 7514525..80b676a 100644 --- a/Configuration/TCA/tx_tea_domain_model_product_tea.php +++ b/Configuration/TCA/tx_tea_domain_model_product_tea.php @@ -1,5 +1,5 @@ [ 'title' => 'LLL:EXT:tea/Resources/Private/Language/locallang_db.xlf:tx_tea_domain_model_product_tea', 'label' => 'title', @@ -32,6 +32,7 @@ return [ 'label' => 'LLL:EXT:tea/Resources/Private/Language/locallang_db.xlf:tx_tea_domain_model_product_tea.description', 'config' => [ 'type' => 'text', + 'enableRichtext' => true, 'rows' => 8, 'cols' => 40, 'max' => 2000, @@ -56,3 +57,9 @@ return [ ], ], ]; + +if (\TYPO3\CMS\Core\Utility\VersionNumberUtility::convertVersionNumberToInteger(TYPO3_version) < 8006000) { + $tca['columns']['description']['defaultExtras'] = 'richtext[]'; +} + +return $tca; diff --git a/Configuration/TypoScript/constants.txt b/Configuration/TypoScript/constants.txt index 2869866..ae3e1aa 100644 --- a/Configuration/TypoScript/constants.txt +++ b/Configuration/TypoScript/constants.txt @@ -16,6 +16,7 @@ plugin.tx_tea { } settings { - + # cat=plugin.tx_tea//a; type=int; label=UID of the page with the single view + singleViewPageUid = } } diff --git a/Configuration/TypoScript/setup.txt b/Configuration/TypoScript/setup.txt index 9311b59..8bcb6fa 100644 --- a/Configuration/TypoScript/setup.txt +++ b/Configuration/TypoScript/setup.txt @@ -10,6 +10,6 @@ plugin.tx_tea { } settings { - + singleViewPageUid = {$plugin.tx_tea.settings.singleViewPageUid} } } diff --git a/Resources/Private/Language/de.locallang.xlf b/Resources/Private/Language/de.locallang.xlf index 94a4ee4..af516f3 100644 --- a/Resources/Private/Language/de.locallang.xlf +++ b/Resources/Private/Language/de.locallang.xlf @@ -15,6 +15,10 @@ Tea list Teeliste + + Tea single view + Tee-Einzelansicht + Our selection of assorted teas Unsere Auswahl an erlesenen Tees diff --git a/Resources/Private/Language/locallang.xlf b/Resources/Private/Language/locallang.xlf index 4d8a893..4102e7a 100644 --- a/Resources/Private/Language/locallang.xlf +++ b/Resources/Private/Language/locallang.xlf @@ -12,6 +12,9 @@ Tea list + + Tea single view + Our selection of assorted teas diff --git a/Resources/Private/Templates/Tea/Index.html b/Resources/Private/Templates/Tea/Index.html index 327b61b..84d6364 100644 --- a/Resources/Private/Templates/Tea/Index.html +++ b/Resources/Private/Templates/Tea/Index.html @@ -15,7 +15,9 @@ {tea.uid} - {tea.title} + + {tea.title} + diff --git a/Resources/Private/Templates/Tea/Show.html b/Resources/Private/Templates/Tea/Show.html new file mode 100644 index 0000000..490e4b2 --- /dev/null +++ b/Resources/Private/Templates/Tea/Show.html @@ -0,0 +1,12 @@ + + + + + +

+ {tea.title} +

+ + {tea.description -> f:format.html()} +
+ diff --git a/Tests/Functional/Controller/Fixtures/Database/pages.xml b/Tests/Functional/Controller/Fixtures/Database/pages.xml index efc9631..c0b3668 100644 --- a/Tests/Functional/Controller/Fixtures/Database/pages.xml +++ b/Tests/Functional/Controller/Fixtures/Database/pages.xml @@ -3,7 +3,7 @@ 1 0 - Root + Tea list 1 15 @@ -27,4 +27,31 @@ ]]> + + 2 + 1 + Tea single view + 1 + 15 + + + 2 + 2 + list + tea_tea + + + + + + + Tea->show + + + + + + ]]> + diff --git a/Tests/Functional/Controller/Fixtures/Frontend/Basic.typoscript b/Tests/Functional/Controller/Fixtures/Frontend/Basic.typoscript index be86e8f..8457ad3 100644 --- a/Tests/Functional/Controller/Fixtures/Frontend/Basic.typoscript +++ b/Tests/Functional/Controller/Fixtures/Frontend/Basic.typoscript @@ -52,3 +52,9 @@ page { file = EXT:tea/Tests/Functional/Controller/Fixtures/Frontend/Template.html } } + +plugin.tx_tea { + settings { + singleViewPageUid = 2 + } +} diff --git a/Tests/Unit/Controller/TeaControllerTest.php b/Tests/Unit/Controller/TeaControllerTest.php index ced6a3f..05e1add 100644 --- a/Tests/Unit/Controller/TeaControllerTest.php +++ b/Tests/Unit/Controller/TeaControllerTest.php @@ -4,6 +4,7 @@ namespace OliverKlee\Tea\Tests\Unit\Controller; use Nimut\TestingFramework\TestCase\UnitTestCase; use OliverKlee\Tea\Controller\TeaController; +use OliverKlee\Tea\Domain\Model\Product\Tea; use OliverKlee\Tea\Domain\Repository\Product\TeaRepository; use Prophecy\Prophecy\ObjectProphecy; use Prophecy\Prophecy\ProphecySubjectInterface; @@ -75,4 +76,15 @@ class TeaControllerTest extends UnitTestCase $this->subject->indexAction(); } + + /** + * @test + */ + public function showActionAssignsPassedTeaAsTeaToView() + { + $tea = new Tea(); + $this->viewProphecy->assign('tea', $tea)->shouldBeCalled(); + + $this->subject->showAction($tea); + } } diff --git a/ext_localconf.php b/ext_localconf.php index 777cb67..749e7fe 100644 --- a/ext_localconf.php +++ b/ext_localconf.php @@ -7,7 +7,7 @@ 'Tea', // all actions [ - 'Tea' => 'index', + 'Tea' => 'index, show', ], // non-cacheable actions [