mirror of
https://github.com/FriendsOfTYPO3/tea.git
synced 2024-11-10 01:16:12 +01:00
[TASK] Use rating controller and index controller in new Plugin (#893)
This commit is contained in:
parent
5349412184
commit
e5e997cfde
10 changed files with 162 additions and 15 deletions
|
@ -2,17 +2,19 @@
|
||||||
|
|
||||||
namespace TTN\Tea\Controller;
|
namespace TTN\Tea\Controller;
|
||||||
|
|
||||||
use Psr\Http\Message\ResponseInterface;
|
use TTN\Tea\Domain\Model\Tea;
|
||||||
use TTN\Tea\Domain\Model\Product\Tea;
|
use TTN\Tea\Domain\Repository\TeaRepository;
|
||||||
use TTN\Tea\Domain\Repository\Product\TeaRepository;
|
use TYPO3\CMS\Extbase\Mvc\Controller\ActionController;
|
||||||
use TYPO3\CMS\Core\Context\Context;
|
|
||||||
use TYPO3\CMS\Extbase\Persistence\Generic\QueryResult;
|
|
||||||
|
|
||||||
class RatingController extends FrontEndEditorController
|
class RatingController extends ActionController
|
||||||
{
|
{
|
||||||
|
|
||||||
|
public function __construct(protected TeaRepository $teaRepository)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
public function ratingAction(Tea $tea, int $stars)
|
public function ratingAction(Tea $tea, int $stars)
|
||||||
{
|
{
|
||||||
$this->checkIfUserIsOwner($tea);
|
|
||||||
$tea->setStars($stars);
|
$tea->setStars($stars);
|
||||||
$this->teaRepository->update($tea);
|
$this->teaRepository->update($tea);
|
||||||
|
|
||||||
|
|
|
@ -30,10 +30,18 @@ call_user_func(
|
||||||
'EXT:tea/Resources/Public/Icons/Extension.svg'
|
'EXT:tea/Resources/Public/Icons/Extension.svg'
|
||||||
);
|
);
|
||||||
|
|
||||||
|
\TYPO3\CMS\Extbase\Utility\ExtensionUtility::registerPlugin(
|
||||||
|
'Tea',
|
||||||
|
'TeaRating',
|
||||||
|
'LLL:EXT:tea/Resources/Private/Language/locallang.xlf:plugin.tea_rating',
|
||||||
|
'EXT:tea/Resources/Public/Icons/Extension.svg'
|
||||||
|
);
|
||||||
|
|
||||||
// This removes the default controls from the plugin.
|
// This removes the default controls from the plugin.
|
||||||
$controlsToRemove = 'recursive,pages';
|
$controlsToRemove = 'recursive,pages';
|
||||||
$GLOBALS['TCA']['tt_content']['types']['list']['subtypes_excludelist']['tea_teaindex'] = $controlsToRemove;
|
$GLOBALS['TCA']['tt_content']['types']['list']['subtypes_excludelist']['tea_teaindex'] = $controlsToRemove;
|
||||||
$GLOBALS['TCA']['tt_content']['types']['list']['subtypes_excludelist']['tea_teashow'] = $controlsToRemove;
|
$GLOBALS['TCA']['tt_content']['types']['list']['subtypes_excludelist']['tea_teashow'] = $controlsToRemove;
|
||||||
$GLOBALS['TCA']['tt_content']['types']['list']['subtypes_excludelist']['tea_teafrontendeditor'] = $controlsToRemove;
|
$GLOBALS['TCA']['tt_content']['types']['list']['subtypes_excludelist']['tea_teafrontendeditor'] = $controlsToRemove;
|
||||||
|
$GLOBALS['TCA']['tt_content']['types']['list']['subtypes_excludelist']['tea_tearating'] = $controlsToRemove;
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
|
@ -21,3 +21,27 @@ plugin.tx_tea {
|
||||||
singleViewPageUid = {$plugin.tx_tea.settings.singleViewPageUid}
|
singleViewPageUid = {$plugin.tx_tea.settings.singleViewPageUid}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
plugin.tx_tea_tearating {
|
||||||
|
view {
|
||||||
|
templateRootPaths {
|
||||||
|
0 = EXT:tea/Resources/Private/Plugins/Rating/Templates/
|
||||||
|
}
|
||||||
|
|
||||||
|
partialRootPaths {
|
||||||
|
0 = EXT:tea/Resources/Private/Plugins/Rating/Partials/
|
||||||
|
}
|
||||||
|
|
||||||
|
layoutRootPaths {
|
||||||
|
0 = EXT:tea/Resources/Private/Plugins/Rating/Layouts/
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
persistence {
|
||||||
|
storagePid = {$plugin.tx_tea.persistence.storagePid}
|
||||||
|
}
|
||||||
|
|
||||||
|
settings {
|
||||||
|
singleViewPageUid = {$plugin.tx_tea_tearating.settings.singleViewPageUid}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -11,6 +11,10 @@
|
||||||
<source>Tea single view</source>
|
<source>Tea single view</source>
|
||||||
<target>Tee-Einzelansicht</target>
|
<target>Tee-Einzelansicht</target>
|
||||||
</trans-unit>
|
</trans-unit>
|
||||||
|
<trans-unit id="plugin.tea_rating" resname="plugin.tea_rating">
|
||||||
|
<source>Tea Rating view</source>
|
||||||
|
<target>Tee-Bewertungsansicht</target>
|
||||||
|
</trans-unit>
|
||||||
<trans-unit id="plugin.tea_frontend_editor" resname="plugin.tea_frontend_editor" approved="yes">
|
<trans-unit id="plugin.tea_frontend_editor" resname="plugin.tea_frontend_editor" approved="yes">
|
||||||
<source>Tea front-end editor</source>
|
<source>Tea front-end editor</source>
|
||||||
<target>Frontend-Editor für Tee</target>
|
<target>Frontend-Editor für Tee</target>
|
||||||
|
|
|
@ -9,6 +9,9 @@
|
||||||
<trans-unit id="plugin.tea_show" resname="plugin.tea_show">
|
<trans-unit id="plugin.tea_show" resname="plugin.tea_show">
|
||||||
<source>Tea single view</source>
|
<source>Tea single view</source>
|
||||||
</trans-unit>
|
</trans-unit>
|
||||||
|
<trans-unit id="plugin.tea_rating" resname="plugin.tea_rating">
|
||||||
|
<source>Tea Rating view</source>
|
||||||
|
</trans-unit>
|
||||||
<trans-unit id="plugin.tea_frontend_editor" resname="plugin.tea_frontend_editor">
|
<trans-unit id="plugin.tea_frontend_editor" resname="plugin.tea_frontend_editor">
|
||||||
<source>Tea front-end editor</source>
|
<source>Tea front-end editor</source>
|
||||||
</trans-unit>
|
</trans-unit>
|
||||||
|
@ -66,6 +69,10 @@
|
||||||
<trans-unit id="plugin.frontEndEditor.new.heading" resname="plugin.frontEndEditor.new.heading">
|
<trans-unit id="plugin.frontEndEditor.new.heading" resname="plugin.frontEndEditor.new.heading">
|
||||||
<source>Create new tea</source>
|
<source>Create new tea</source>
|
||||||
</trans-unit>
|
</trans-unit>
|
||||||
|
<trans-unit id="plugin.tea.filter.rating" resname="plugin.tea.filter.rating">
|
||||||
|
<source>Filter by rating</source>
|
||||||
|
</trans-unit>
|
||||||
|
|
||||||
</body>
|
</body>
|
||||||
</file>
|
</file>
|
||||||
</xliff>
|
</xliff>
|
||||||
|
|
|
@ -0,0 +1,41 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html xmlns:f="http://typo3.org/ns/TYPO3/CMS/Fluid/ViewHelpers" data-namespace-typo3-fluid="true">
|
||||||
|
<f:layout name="Default"/>
|
||||||
|
|
||||||
|
<f:section name="main">
|
||||||
|
<h2>
|
||||||
|
Rating Plugin: <f:translate key="plugin.tea.heading"/>
|
||||||
|
</h2>
|
||||||
|
<f:link.action action="filter" controller="Rating" arguments="{stars:1}">1</f:link.action>
|
||||||
|
<f:link.action action="filter" controller="Rating" arguments="{tea:tea,stars:2}">2</f:link.action>
|
||||||
|
<f:link.action action="filter" controller="Rating" arguments="{tea:tea,stars:3}">3</f:link.action>
|
||||||
|
<f:link.action action="filter" controller="Rating" arguments="{tea:tea,stars:4}">4</f:link.action>
|
||||||
|
<f:link.action action="filter" controller="Rating" arguments="{tea:tea,stars:5}">5</f:link.action>
|
||||||
|
<table class="table">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>
|
||||||
|
<f:translate key="plugin.tea.property.uid"/>
|
||||||
|
</th>
|
||||||
|
<th>
|
||||||
|
<f:translate key="plugin.tea.property.title"/>
|
||||||
|
</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<f:for each="{teas}" as="tea">
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
{tea.uid}
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<f:link.action action="show" arguments="{tea: tea}" pageUid="{settings.singleViewPageUid}">
|
||||||
|
{tea.title}
|
||||||
|
</f:link.action>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</f:for>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</f:section>
|
||||||
|
</html>
|
42
Resources/Private/Plugins/Rating/Templates/Tea/Index.html
Normal file
42
Resources/Private/Plugins/Rating/Templates/Tea/Index.html
Normal file
|
@ -0,0 +1,42 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html xmlns:f="http://typo3.org/ns/TYPO3/CMS/Fluid/ViewHelpers" data-namespace-typo3-fluid="true">
|
||||||
|
<f:layout name="Default"/>
|
||||||
|
|
||||||
|
<f:section name="main">
|
||||||
|
<h2>
|
||||||
|
<f:translate key="plugin.tea.heading"/>
|
||||||
|
</h2>
|
||||||
|
<f:translate key="plugin.tea.filter.rating"/>
|
||||||
|
<f:link.action action="filter" controller="Rating" arguments="{stars:1}">1</f:link.action>
|
||||||
|
<f:link.action action="filter" controller="Rating" arguments="{tea:tea,stars:2}">2</f:link.action>
|
||||||
|
<f:link.action action="filter" controller="Rating" arguments="{tea:tea,stars:3}">3</f:link.action>
|
||||||
|
<f:link.action action="filter" controller="Rating" arguments="{tea:tea,stars:4}">4</f:link.action>
|
||||||
|
<f:link.action action="filter" controller="Rating" arguments="{tea:tea,stars:5}">5</f:link.action>
|
||||||
|
<table class="table">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>
|
||||||
|
<f:translate key="plugin.tea.property.uid"/>
|
||||||
|
</th>
|
||||||
|
<th>
|
||||||
|
<f:translate key="plugin.tea.property.title"/>
|
||||||
|
</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<f:for each="{teas}" as="tea">
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
{tea.uid}
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<f:link.action pluginName="tearaing" action="show" arguments="{tea: tea}" pageUid="{settings.singleViewPageUid}">
|
||||||
|
{tea.title}
|
||||||
|
</f:link.action>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</f:for>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</f:section>
|
||||||
|
</html>
|
12
Resources/Private/Plugins/Rating/Templates/Tea/Show.html
Normal file
12
Resources/Private/Plugins/Rating/Templates/Tea/Show.html
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html xmlns:f="http://typo3.org/ns/TYPO3/CMS/Fluid/ViewHelpers" data-namespace-typo3-fluid="true">
|
||||||
|
<f:layout name="Default"/>
|
||||||
|
|
||||||
|
<f:section name="main">
|
||||||
|
<h2>
|
||||||
|
Rating Plugin: {tea.title}
|
||||||
|
</h2>
|
||||||
|
|
||||||
|
{tea.description -> f:format.html()}
|
||||||
|
</f:section>
|
||||||
|
</html>
|
|
@ -6,11 +6,6 @@
|
||||||
<h2>
|
<h2>
|
||||||
<f:translate key="plugin.tea.heading"/>
|
<f:translate key="plugin.tea.heading"/>
|
||||||
</h2>
|
</h2>
|
||||||
<f:link.action action="filter" controller="Rating" arguments="{stars:1}">1</f:link.action>
|
|
||||||
<f:link.action action="filter" controller="Rating" arguments="{tea:tea,stars:2}">2</f:link.action>
|
|
||||||
<f:link.action action="filter" controller="Rating" arguments="{tea:tea,stars:3}">3</f:link.action>
|
|
||||||
<f:link.action action="filter" controller="Rating" arguments="{tea:tea,stars:4}">4</f:link.action>
|
|
||||||
<f:link.action action="filter" controller="Rating" arguments="{tea:tea,stars:5}">5</f:link.action>
|
|
||||||
<table class="table">
|
<table class="table">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
|
|
|
@ -18,7 +18,6 @@ ExtensionUtility::configurePlugin(
|
||||||
// all actions
|
// all actions
|
||||||
[
|
[
|
||||||
TeaController::class => 'index',
|
TeaController::class => 'index',
|
||||||
RatingController::class => 'filter'
|
|
||||||
],
|
],
|
||||||
// non-cacheable actions
|
// non-cacheable actions
|
||||||
[
|
[
|
||||||
|
@ -45,13 +44,26 @@ ExtensionUtility::configurePlugin(
|
||||||
// all actions
|
// all actions
|
||||||
[
|
[
|
||||||
FrontEndEditorController::class => 'index, edit, update, create, new, delete',
|
FrontEndEditorController::class => 'index, edit, update, create, new, delete',
|
||||||
RatingController::class => 'filter,rating'
|
|
||||||
],
|
],
|
||||||
// non-cacheable actions
|
// non-cacheable actions
|
||||||
[
|
[
|
||||||
// All actions need to be non-cacheable because they either contain dynamic data,
|
// All actions need to be non-cacheable because they either contain dynamic data,
|
||||||
// or because they are specific to the logged-in FE user (while FE content is cached by FE groups).
|
// or because they are specific to the logged-in FE user (while FE content is cached by FE groups).
|
||||||
FrontEndEditorController::class => 'index, edit, update, create, new, delete',
|
FrontEndEditorController::class => 'index, edit, update, create, new, delete',
|
||||||
RatingController::class => 'rating'
|
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// Combine TeaController and RatingController into a new Plugin
|
||||||
|
ExtensionUtility::configurePlugin(
|
||||||
|
'Tea',
|
||||||
|
'TeaRating',
|
||||||
|
[
|
||||||
|
TeaController::class => 'index',
|
||||||
|
RatingController::class => 'filter,rating'
|
||||||
|
],
|
||||||
|
[
|
||||||
|
TeaController::class => 'index',
|
||||||
|
RatingController::class => 'rating,filter'
|
||||||
|
]
|
||||||
|
);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue