mirror of https://github.com/FriendsOfTYPO3/tea.git synced 2024-12-22 13:46:11 +01:00

[FEATURE] Tea single view (#26)

This commit is contained in:
Oliver Klee 2018-05-28 17:05:39 +02:00 committed by GitHub
parent 3e4d10cc12
commit 3e1fd7416f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
13 changed files with 95 additions and 6 deletions

View file

@ -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);
}
}

View file

@ -24,6 +24,10 @@
<numIndex index="0">LLL:EXT:tea/Resources/Private/Language/locallang.xlf:plugin.tea.index</numIndex>
<numIndex index="1">Tea->index</numIndex>
</numIndex>
<numIndex index="2" type="array">
<numIndex index="0">LLL:EXT:tea/Resources/Private/Language/locallang.xlf:plugin.tea.show</numIndex>
<numIndex index="1">Tea->show</numIndex>
</numIndex>
</items>
</config>
</TCEforms>

View file

@ -1,5 +1,5 @@
<?php
return [
$tca = [
'ctrl' => [
'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;

View file

@ -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 =
}
}

View file

@ -10,6 +10,6 @@ plugin.tx_tea {
}
settings {
singleViewPageUid = {$plugin.tx_tea.settings.singleViewPageUid}
}
}

View file

@ -15,6 +15,10 @@
<source>Tea list</source>
<target>Teeliste</target>
</trans-unit>
<trans-unit id="plugin.tea.show">
<source>Tea single view</source>
<target>Tee-Einzelansicht</target>
</trans-unit>
<trans-unit id="index.heading">
<source>Our selection of assorted teas</source>
<target>Unsere Auswahl an erlesenen Tees</target>

View file

@ -12,6 +12,9 @@
<trans-unit id="plugin.tea.index">
<source>Tea list</source>
</trans-unit>
<trans-unit id="plugin.tea.show">
<source>Tea single view</source>
</trans-unit>
<trans-unit id="index.heading">
<source>Our selection of assorted teas</source>
</trans-unit>

View file

@ -15,7 +15,9 @@
{tea.uid}
</td>
<td>
{tea.title}
<f:link.action arguments="{tea: tea}" pageUid="{settings.singleViewPageUid}">
{tea.title}
</f:link.action>
</td>
</tr>
</f:for>

View file

@ -0,0 +1,12 @@
<!DOCTYPE html>
<html xmlns:f="https://xsd.helhum.io/ns/typo3/cms-fluid/master/ViewHelpers" data-namespace-typo3-fluid="true">
<f:layout name="Default"/>
<f:section name="main">
<h2>
{tea.title}
</h2>
{tea.description -> f:format.html()}
</f:section>
</html>

View file

@ -3,7 +3,7 @@
<pages>
<uid>1</uid>
<pid>0</pid>
<title>Root</title>
<title>Tea list</title>
<doktype>1</doktype>
<perms_everybody>15</perms_everybody>
</pages>
@ -27,4 +27,31 @@
</T3FlexForms>
]]></pi_flexform>
</tt_content>
<pages>
<uid>2</uid>
<pid>1</pid>
<title>Tea single view</title>
<doktype>1</doktype>
<perms_everybody>15</perms_everybody>
</pages>
<tt_content>
<uid>2</uid>
<pid>2</pid>
<CType>list</CType>
<list_type>tea_tea</list_type>
<pi_flexform><![CDATA[
<?xml version="1.0" encoding="utf-8" standalone="yes" ?>
<T3FlexForms>
<data>
<sheet index="general">
<language index="lDEF">
<field index="switchableControllerActions">
<value index="vDEF">Tea-&gt;show</value>
</field>
</language>
</sheet>
</data>
</T3FlexForms>
]]></pi_flexform>
</tt_content>
</dataset>

View file

@ -52,3 +52,9 @@ page {
file = EXT:tea/Tests/Functional/Controller/Fixtures/Frontend/Template.html
}
}
plugin.tx_tea {
settings {
singleViewPageUid = 2
}
}

View file

@ -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);
}
}

View file

@ -7,7 +7,7 @@
'Tea',
// all actions
[
'Tea' => 'index',
'Tea' => 'index, show',
],
// non-cacheable actions
[