From 5f9a198d9cf89c7707734e42dc1107a846e903ef Mon Sep 17 00:00:00 2001
From: Nicolas Barbey <223106@supinfo.com>
Date: Tue, 27 Jul 2021 15:03:04 +0200
Subject: [PATCH 1/2] Thelia 2.5 compatibility
---
Action/CommentAction.php | 25 +-
Comment.php | 23 +-
Config/config.xml | 12 +-
Config/module.xml | 4 +-
Config/routing.xml | 15 +-
Config/schema.xml | 2 +-
Controller/Back/CommentController.php | 74 +-
Controller/Front/CommentController.php | 88 +-
Form/AddCommentForm.php | 18 +-
Form/CommentAbuseForm.php | 6 +-
Form/CommentCreationForm.php | 29 +-
Form/CommentModificationForm.php | 5 +-
Form/ConfigurationForm.php | 19 +-
Hook/FrontHook.php | 8 +-
Loop/CommentLoop.php | 11 +-
Model/Base/Comment.php | 2020 -----------------
Model/Base/CommentQuery.php | 1057 ---------
Model/Map/CommentTableMap.php | 528 -----
.../backOffice/default/comment-edit.html | 4 +-
.../backOffice/default/configuration.html | 2 +-
.../default/include/comments-list.html | 18 +-
.../frontOffice/default/ajax-comments.html | 2 +-
templates/frontOffice/default/comment.html | 2 +-
23 files changed, 214 insertions(+), 3758 deletions(-)
delete mode 100755 Model/Base/Comment.php
delete mode 100755 Model/Base/CommentQuery.php
delete mode 100755 Model/Map/CommentTableMap.php
diff --git a/Action/CommentAction.php b/Action/CommentAction.php
index 0fd876c..2ed0d36 100644
--- a/Action/CommentAction.php
+++ b/Action/CommentAction.php
@@ -42,8 +42,9 @@
use DateTime;
use Propel\Runtime\ActiveQuery\Criteria;
use Propel\Runtime\ActiveQuery\Join;
+use Symfony\Component\EventDispatcher\EventDispatcherInterface;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
-use Symfony\Component\Translation\TranslatorInterface;
+use Symfony\Contracts\Translation\TranslatorInterface;
use Thelia\Core\Template\ParserInterface;
use Thelia\Core\Translation\Translator;
use Thelia\Log\Tlog;
@@ -81,11 +82,15 @@ class CommentAction implements EventSubscriberInterface
/** @var null|MailerFactory */
protected $mailer = null;
- public function __construct(TranslatorInterface $translator, ParserInterface $parser, MailerFactory $mailer)
+ /** @var null|EventDispatcherInterface */
+ protected $dispatcher = null;
+
+ public function __construct(TranslatorInterface $translator, ParserInterface $parser, MailerFactory $mailer, EventDispatcherInterface $dispatcher)
{
$this->translator = $translator;
$this->parser = $parser;
$this->mailer = $mailer;
+ $this->dispatcher = $dispatcher;
}
public function create(CommentCreateEvent $event)
@@ -111,7 +116,6 @@ public function create(CommentCreateEvent $event)
if (Comment::ACCEPTED === $comment->getStatus()) {
$this->dispatchRatingCompute(
- $event->getDispatcher(),
$comment->getRef(),
$comment->getRefId()
);
@@ -138,7 +142,6 @@ public function update(CommentUpdateEvent $event)
$event->setComment($comment);
$this->dispatchRatingCompute(
- $event->getDispatcher(),
$comment->getRef(),
$comment->getRefId()
);
@@ -154,7 +157,6 @@ public function delete(CommentDeleteEvent $event)
if (Comment::ACCEPTED === $comment->getStatus()) {
$this->dispatchRatingCompute(
- $event->getDispatcher(),
$comment->getRef(),
$comment->getRefId()
);
@@ -184,7 +186,6 @@ public function statusChange(CommentChangeStatusEvent $event)
$event->setComment($comment);
$this->dispatchRatingCompute(
- $event->getDispatcher(),
$comment->getRef(),
$comment->getRefId()
);
@@ -230,7 +231,7 @@ public function productRatingCompute(CommentComputeRatingEvent $event)
* @param string $ref
* @param int $refId
*/
- protected function dispatchRatingCompute($dispatcher, $ref, $refId)
+ protected function dispatchRatingCompute($ref, $refId)
{
$ratingEvent = new CommentComputeRatingEvent();
@@ -238,9 +239,9 @@ protected function dispatchRatingCompute($dispatcher, $ref, $refId)
->setRef($ref)
->setRefId($refId);
- $dispatcher->dispatch(
- CommentEvents::COMMENT_RATING_COMPUTE,
- $ratingEvent
+ $this->dispatcher->dispatch(
+ $ratingEvent,
+ CommentEvents::COMMENT_RATING_COMPUTE
);
}
@@ -292,7 +293,7 @@ public function getDefinition(CommentDefinitionEvent $event)
}
$eventName = CommentEvents::COMMENT_GET_DEFINITION . "." . $event->getRef();
- $event->getDispatcher()->dispatch($eventName, $event);
+ $this->dispatcher->dispatch($event, $eventName);
// is only customer is authorized to publish
if ($config['only_customer'] && null === $event->getCustomer()) {
@@ -612,7 +613,7 @@ public function notifyAdminOfNewComment(CommentCreateEvent $event)
$comment->getRefId(),
$shopLocale
);
- $event->getDispatcher()->dispatch(CommentEvents::COMMENT_REFERENCE_GETTER, $getCommentRefEvent);
+ $this->dispatcher->dispatch($getCommentRefEvent, CommentEvents::COMMENT_REFERENCE_GETTER);
$this->mailer->sendEmailToShopManagers(
'new_comment_notification_admin',
diff --git a/Comment.php b/Comment.php
index e3c74c5..aecaf9a 100755
--- a/Comment.php
+++ b/Comment.php
@@ -14,6 +14,7 @@
use Comment\Model\CommentQuery;
use Propel\Runtime\Connection\ConnectionInterface;
+use Symfony\Component\DependencyInjection\Loader\Configurator\ServicesConfigurator;
use Thelia\Core\Translation\Translator;
use Thelia\Install\Database;
use Thelia\Model\ConfigQuery;
@@ -57,7 +58,7 @@ class Comment extends BaseModule
const CONFIG_NOTIFY_ADMIN_NEW_COMMENT = true;
- public function postActivation(ConnectionInterface $con = null)
+ public function postActivation(ConnectionInterface $con = null): void
{
// Config
if (null === ConfigQuery::read('comment_activated')) {
@@ -180,30 +181,38 @@ public static function getConfig()
{
$config = [
'activated' => (
- intval(ConfigQuery::read('comment_activated', self::CONFIG_ACTIVATED)) === 1
+ (int)ConfigQuery::read('comment_activated', self::CONFIG_ACTIVATED) === 1
),
'moderate' => (
- intval(ConfigQuery::read('comment_moderate', self::CONFIG_MODERATE)) === 1
+ (int)ConfigQuery::read('comment_moderate', self::CONFIG_MODERATE) === 1
),
'ref_allowed' => explode(
',',
ConfigQuery::read('comment_ref_allowed', self::CONFIG_REF_ALLOWED)
),
'only_customer' => (
- intval(ConfigQuery::read('comment_only_customer', self::CONFIG_ONLY_CUSTOMER)) === 1
+ (int)ConfigQuery::read('comment_only_customer', self::CONFIG_ONLY_CUSTOMER) === 1
),
'only_verified' => (
- intval(ConfigQuery::read('comment_only_verified', self::CONFIG_ONLY_VERIFIED)) === 1
+ (int)ConfigQuery::read('comment_only_verified', self::CONFIG_ONLY_VERIFIED) === 1
),
'request_customer_ttl' => (
- intval(ConfigQuery::read('comment_request_customer_ttl', self::CONFIG_REQUEST_CUSTOMMER_TTL))
+ (int)ConfigQuery::read('comment_request_customer_ttl', self::CONFIG_REQUEST_CUSTOMMER_TTL)
),
'notify_admin_new_comment' => (
- intval(ConfigQuery::read('comment_notify_admin_new_comment', self::CONFIG_NOTIFY_ADMIN_NEW_COMMENT))
+ (int)ConfigQuery::read('comment_notify_admin_new_comment', self::CONFIG_NOTIFY_ADMIN_NEW_COMMENT)
=== 1
),
];
return $config;
}
+
+ public static function configureServices(ServicesConfigurator $servicesConfigurator): void
+ {
+ $servicesConfigurator->load(self::getModuleCode().'\\', __DIR__)
+ ->exclude([THELIA_MODULE_DIR . ucfirst(self::getModuleCode()). "/I18n/*"])
+ ->autowire(true)
+ ->autoconfigure(true);
+ }
}
diff --git a/Config/config.xml b/Config/config.xml
index 1e24164..858bf92 100755
--- a/Config/config.xml
+++ b/Config/config.xml
@@ -9,10 +9,10 @@
-
-
-
-
+
+
+
+
@@ -21,7 +21,7 @@
-->
-
+
- -->
-
+
-