From 786047e6858c0b81e5f5f23c496f23688871d1a3 Mon Sep 17 00:00:00 2001 From: zkabic Date: Wed, 8 Nov 2023 16:29:20 +0100 Subject: [PATCH] Add my logger --- .../DontChangeArticleUpdateAtListener.php | 3 +++ .../CoreBundle/Service/ArticlePublisher.php | 3 +++ src/SWP/Bundle/CoreBundle/Util/SwpLogger.php | 20 +++++++++++++++++++ 3 files changed, 26 insertions(+) create mode 100644 src/SWP/Bundle/CoreBundle/Util/SwpLogger.php diff --git a/src/SWP/Bundle/CoreBundle/EventListener/DontChangeArticleUpdateAtListener.php b/src/SWP/Bundle/CoreBundle/EventListener/DontChangeArticleUpdateAtListener.php index 3e1e6ddce..6ee9c3e4b 100644 --- a/src/SWP/Bundle/CoreBundle/EventListener/DontChangeArticleUpdateAtListener.php +++ b/src/SWP/Bundle/CoreBundle/EventListener/DontChangeArticleUpdateAtListener.php @@ -28,12 +28,15 @@ public function __construct(SettingsManagerInterface $settingsManager, TenantCon public function setUpdateAtDate(ArticleEvent $event): void { + SwpLogger::log('Listener is in use :-) ....'); $article = $event->getArticle(); /** * @var ?ArticleExtraTextField $dontUpdateDate */ $dontUpdateDate = $article->getExtraByKey('dont_change_updated_at') ?? null; + SwpLogger::log('Dont update date is type of: ' . gettype($dontUpdateDate)); if ($dontUpdateDate instanceof ArticleExtraTextField && strtolower($dontUpdateDate->getValue()) === 'on') { + SwpLogger::log('Dont update date: ' . $dontUpdateDate->getValue()); $article->cancelTimestampable(); } } diff --git a/src/SWP/Bundle/CoreBundle/Service/ArticlePublisher.php b/src/SWP/Bundle/CoreBundle/Service/ArticlePublisher.php index 3fdf2bfa3..d1c01f363 100644 --- a/src/SWP/Bundle/CoreBundle/Service/ArticlePublisher.php +++ b/src/SWP/Bundle/CoreBundle/Service/ArticlePublisher.php @@ -29,6 +29,7 @@ use SWP\Bundle\CoreBundle\Model\PublishDestinationInterface; use SWP\Bundle\CoreBundle\Model\TenantInterface; use SWP\Bundle\CoreBundle\Repository\ContentListItemRepository; +use SWP\Bundle\CoreBundle\Util\SwpLogger; use SWP\Component\Bridge\Events; use SWP\Component\ContentList\Model\ContentListInterface; use SWP\Component\ContentList\Repository\ContentListRepositoryInterface; @@ -136,7 +137,9 @@ public function publish(PackageInterface $package, CompositePublishActionInterfa $article->setPublishedToAppleNews($destination->isPublishedToAppleNews()); $this->eventDispatcher->dispatch(new GenericEvent($article), Events::SWP_VALIDATION); $this->eventDispatcher->dispatch(new ArticleEvent($article, $package, ArticleEvents::PRE_UPDATE, $article->getRoute()), ArticleEvents::PRE_UPDATE); + SwpLogger::log('PRE_UPDATE before flush: ' . ($article->isTimestampableCanceled() ? 'Y' : 'N')); $this->articleRepository->flush(); + SwpLogger::log('PRE_UPDATE after flush: ' . ($article->isTimestampableCanceled() ? 'Y' : 'N')); if ($destination->isPublished()) { $this->eventDispatcher->dispatch(new ArticleEvent($article, $package, ArticleEvents::PUBLISH), ArticleEvents::PUBLISH); diff --git a/src/SWP/Bundle/CoreBundle/Util/SwpLogger.php b/src/SWP/Bundle/CoreBundle/Util/SwpLogger.php new file mode 100644 index 000000000..dc81b029b --- /dev/null +++ b/src/SWP/Bundle/CoreBundle/Util/SwpLogger.php @@ -0,0 +1,20 @@ +