diff --git a/Classes/Controller/FrontEndEditorController.php b/Classes/Controller/FrontEndEditorController.php
index 8b2c50c..1d568ca 100644
--- a/Classes/Controller/FrontEndEditorController.php
+++ b/Classes/Controller/FrontEndEditorController.php
@@ -19,7 +19,7 @@ class FrontEndEditorController extends ActionController
{
private Context $context;
- private TeaRepository $teaRepository;
+ protected TeaRepository $teaRepository;
public function __construct(Context $context, TeaRepository $teaRepository)
{
@@ -63,7 +63,7 @@ class FrontEndEditorController extends ActionController
/**
* @throws \RuntimeException
*/
- private function checkIfUserIsOwner(Tea $tea): void
+ protected function checkIfUserIsOwner(Tea $tea): void
{
if ($tea->getOwnerUid() !== $this->getUidOfLoggedInUser()) {
throw new \RuntimeException('You do not have the permissions to edit this tea.', 1687363749);
diff --git a/Classes/Controller/RatingController.php b/Classes/Controller/RatingController.php
new file mode 100644
index 0000000..7d539b0
--- /dev/null
+++ b/Classes/Controller/RatingController.php
@@ -0,0 +1,30 @@
+setStars($stars);
+ $this->teaRepository->update($tea);
+
+ return $this->redirect('index','FrontEndEditor');
+ }
+
+ public function filterAction(int $stars)
+ {
+ $this->view->assign('teas', $this->teaRepository->findByStars($stars));
+ return $this->htmlResponse();
+ }
+
+}
diff --git a/Classes/Domain/Model/Tea.php b/Classes/Domain/Model/Tea.php
index 7ce31a0..a1867fa 100644
--- a/Classes/Domain/Model/Tea.php
+++ b/Classes/Domain/Model/Tea.php
@@ -32,6 +32,11 @@ class Tea extends AbstractEntity
*/
protected $image;
+ /**
+ * @var int
+ */
+ protected $stars = null;
+
// Note: We cannot use `@var` for the more specific type annotation here as this confuses the Extbase type mapper.
/**
@@ -90,4 +95,23 @@ class Tea extends AbstractEntity
{
$this->ownerUid = $ownerUid;
}
+
+ /**
+ * @return int|null
+ */
+ public function getStars(): ?int
+ {
+ return $this->stars;
+ }
+
+ /**
+ * @param int|null $stars
+ * @return void
+ */
+ public function setStars(?int $stars): void
+ {
+ $this->stars = $stars;
+ }
+
+
}
diff --git a/Configuration/TCA/Overrides/tt_content.php b/Configuration/TCA/Overrides/tt_content.php
index 74531e3..b3008b1 100644
--- a/Configuration/TCA/Overrides/tt_content.php
+++ b/Configuration/TCA/Overrides/tt_content.php
@@ -32,10 +32,18 @@ call_user_func(
'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.
$controlsToRemove = 'recursive,pages';
$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_teafrontendeditor'] = $controlsToRemove;
+ $GLOBALS['TCA']['tt_content']['types']['list']['subtypes_excludelist']['tea_tearating'] = $controlsToRemove;
}
);
diff --git a/Configuration/TCA/tx_tea_domain_model_tea.php b/Configuration/TCA/tx_tea_domain_model_tea.php
index f1b6b6c..0aa3c0a 100644
--- a/Configuration/TCA/tx_tea_domain_model_tea.php
+++ b/Configuration/TCA/tx_tea_domain_model_tea.php
@@ -29,8 +29,8 @@ $tca = [
'1' => [
'showitem' =>
'--div--;LLL:EXT:core/Resources/Private/Language/Form/locallang_tabs.xlf:general,
- title, description, image, owner,
- --div--;LLL:EXT:tea/Resources/Private/Language/locallang_db.xlf:tx_tea_domain_model_tea.tabs.access,
+ title, description, image, stars, owner,
+ --div--;LLL:EXT:tea/Resources/Private/Language/locallang_db.xlf:tx_tea_domain_model_product_tea.tabs.access,
--palette--;;hidden,
--palette--;;access,',
],
@@ -206,6 +206,16 @@ $tca = [
'hideSuggest' => true,
],
],
+ 'stars' => [
+ 'exclude' => true,
+ 'label' => 'LLL:EXT:tea/Resources/Private/Language/locallang_db.xlf:tx_tea_domain_model_product_tea.stars',
+ 'config' => [
+ 'type' => 'input',
+ 'size' => 8,
+ 'eval' => 'trim',
+ 'max' => 255,
+ ]
+ ],
],
];
diff --git a/Configuration/TypoScript/setup.typoscript b/Configuration/TypoScript/setup.typoscript
index 4de562a..2dc2c2b 100644
--- a/Configuration/TypoScript/setup.typoscript
+++ b/Configuration/TypoScript/setup.typoscript
@@ -21,3 +21,27 @@ plugin.tx_tea {
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}
+ }
+}
diff --git a/Resources/Private/Language/de.locallang.xlf b/Resources/Private/Language/de.locallang.xlf
index d7a0e67..ec6bbfd 100644
--- a/Resources/Private/Language/de.locallang.xlf
+++ b/Resources/Private/Language/de.locallang.xlf
@@ -11,6 +11,10 @@
Tee-Einzelansicht
+
+
+ Tee-Bewertungsansicht
+
Frontend-Editor für Tee
@@ -27,6 +31,10 @@
Titel
+
+
+ Sterne
+
Meine Tees
@@ -55,6 +63,10 @@
Aktionen
+
+
+ Bewertung
+
Bearbeiten
diff --git a/Resources/Private/Language/de.locallang_db.xlf b/Resources/Private/Language/de.locallang_db.xlf
index c05d691..dc58c8a 100644
--- a/Resources/Private/Language/de.locallang_db.xlf
+++ b/Resources/Private/Language/de.locallang_db.xlf
@@ -35,6 +35,10 @@
Sichtbar
+
+
+ Sterne
+