From e5659489a4d95f44f492005b9ecf16ecb5148dae Mon Sep 17 00:00:00 2001 From: Adam Schubert Date: Thu, 4 Jan 2018 15:46:14 +0100 Subject: [PATCH] Cleanup + migration to Nette\SmartObject + new dravencms\locale --- .../HtmlSnippetGrid/HtmlSnippetGrid.php | 10 ++++------ .../HtmlSnippet/HtmlSnippet/Detail/Detail.php | 17 +++++++++++++---- .../Repository/HtmlSnippetCmsRepository.php | 9 ++++----- .../Repository/HtmlSnippetRepository.php | 4 +--- .../HtmlSnippetTranslationRepository.php | 4 ---- 5 files changed, 22 insertions(+), 22 deletions(-) diff --git a/src/Dravencms/AdminModule/Components/HtmlSnippet/HtmlSnippetGrid/HtmlSnippetGrid.php b/src/Dravencms/AdminModule/Components/HtmlSnippet/HtmlSnippetGrid/HtmlSnippetGrid.php index e71308f..29c728b 100644 --- a/src/Dravencms/AdminModule/Components/HtmlSnippet/HtmlSnippetGrid/HtmlSnippetGrid.php +++ b/src/Dravencms/AdminModule/Components/HtmlSnippet/HtmlSnippetGrid/HtmlSnippetGrid.php @@ -23,11 +23,8 @@ use Dravencms\Components\BaseControl\BaseControl; use Dravencms\Components\BaseGrid\BaseGridFactory; -use Dravencms\Locale\CurrentLocale; -use Dravencms\Model\Article\Entities\Group; -use Dravencms\Model\Article\Repository\ArticleRepository; +use Dravencms\Locale\CurrentLocaleResolver; use Dravencms\Model\HtmlSnippet\Repository\HtmlSnippetRepository; -use Dravencms\Model\Locale\Repository\LocaleRepository; use Kdyby\Doctrine\EntityManager; /** @@ -47,6 +44,7 @@ class HtmlSnippetGrid extends BaseControl /** @var EntityManager */ private $entityManager; + /** @var ILocale */ private $currentLocale; /** @@ -58,14 +56,14 @@ public function __construct( HtmlSnippetRepository $htmlSnippetRepository, BaseGridFactory $baseGridFactory, EntityManager $entityManager, - CurrentLocale $currentLocale + CurrentLocaleResolver $currentLocaleResolver ) { parent::__construct(); $this->baseGridFactory = $baseGridFactory; $this->htmlSnippetRepository = $htmlSnippetRepository; - $this->currentLocale = $currentLocale; + $this->currentLocale = $currentLocaleResolver->getCurrentLocale(); $this->entityManager = $entityManager; } diff --git a/src/Dravencms/FrontModule/Components/HtmlSnippet/HtmlSnippet/Detail/Detail.php b/src/Dravencms/FrontModule/Components/HtmlSnippet/HtmlSnippet/Detail/Detail.php index 90ee430..fe1b0ba 100644 --- a/src/Dravencms/FrontModule/Components/HtmlSnippet/HtmlSnippet/Detail/Detail.php +++ b/src/Dravencms/FrontModule/Components/HtmlSnippet/HtmlSnippet/Detail/Detail.php @@ -3,7 +3,7 @@ namespace Dravencms\FrontModule\Components\HtmlSnippet\HtmlSnippet\Detail; use Dravencms\Components\BaseControl\BaseControl; -use Dravencms\Locale\CurrentLocale; +use Dravencms\Locale\CurrentLocaleResolver; use Dravencms\Model\HtmlSnippet\Repository\HtmlSnippetRepository; use Dravencms\Model\HtmlSnippet\Repository\HtmlSnippetTranslationRepository; use Nette\Caching\Cache; @@ -19,7 +19,7 @@ class Detail extends BaseControl /** @var ICmsActionOption */ private $cmsActionOption; - /** @var CurrentLocale */ + /** @var ILocale */ private $currentLocale; /** @var HtmlSnippetTranslationRepository */ @@ -31,11 +31,20 @@ class Detail extends BaseControl /** @var Tempnam */ private $tempnam; + /** + * Detail constructor. + * @param ICmsActionOption $cmsActionOption + * @param HtmlSnippetRepository $htmlSnippetRepository + * @param HtmlSnippetTranslationRepository $htmlSnippetTranslationRepository + * @param CurrentLocaleResolver $currentLocaleResolver + * @param IStorage $storage + * @param Tempnam $tempnam + */ public function __construct( ICmsActionOption $cmsActionOption, HtmlSnippetRepository $htmlSnippetRepository, HtmlSnippetTranslationRepository $htmlSnippetTranslationRepository, - CurrentLocale $currentLocale, + CurrentLocaleResolver $currentLocaleResolver, IStorage $storage, Tempnam $tempnam ) @@ -44,7 +53,7 @@ public function __construct( $this->cmsActionOption = $cmsActionOption; $this->htmlSnippetRepository = $htmlSnippetRepository; $this->htmlSnippetTranslationRepository = $htmlSnippetTranslationRepository; - $this->currentLocale = $currentLocale; + $this->currentLocale = $currentLocaleResolver->getCurrentLocale(); $this->tempnam = $tempnam; $this->cache = new Cache($storage, __CLASS__); } diff --git a/src/Dravencms/Model/HtmlSnippet/Repository/HtmlSnippetCmsRepository.php b/src/Dravencms/Model/HtmlSnippet/Repository/HtmlSnippetCmsRepository.php index 7417a91..9bce17a 100644 --- a/src/Dravencms/Model/HtmlSnippet/Repository/HtmlSnippetCmsRepository.php +++ b/src/Dravencms/Model/HtmlSnippet/Repository/HtmlSnippetCmsRepository.php @@ -5,7 +5,6 @@ namespace Dravencms\Model\HtmlSnippet\Repository; -use Dravencms\Model\Article\Entities\Article; use Dravencms\Model\HtmlSnippet\Entities\HtmlSnippet; use Nette; use Salamek\Cms\CmsActionOption; @@ -33,9 +32,9 @@ public function getActionOptions($componentAction) { case 'Detail': $return = []; - /** @var HtmlSnippet $article */ - foreach ($this->htmlSnippetRepository->getActive() AS $article) { - $return[] = new CmsActionOption($article->getIdentifier(), ['id' => $article->getId()]); + /** @var HtmlSnippet $htmlSnippet */ + foreach ($this->htmlSnippetRepository->getActive() AS $htmlSnippet) { + $return[] = new CmsActionOption($htmlSnippet->getIdentifier(), ['id' => $htmlSnippet->getId()]); } break; @@ -55,7 +54,7 @@ public function getActionOptions($componentAction) */ public function getActionOption($componentAction, array $parameters) { - /** @var Article $found */ + /** @var HtmlSnippet $found */ $found = $this->htmlSnippetRepository->getOneByParameters($parameters + ['isActive' => true]); if ($found) diff --git a/src/Dravencms/Model/HtmlSnippet/Repository/HtmlSnippetRepository.php b/src/Dravencms/Model/HtmlSnippet/Repository/HtmlSnippetRepository.php index dd1a1b3..b0f1f2f 100644 --- a/src/Dravencms/Model/HtmlSnippet/Repository/HtmlSnippetRepository.php +++ b/src/Dravencms/Model/HtmlSnippet/Repository/HtmlSnippetRepository.php @@ -5,8 +5,6 @@ namespace Dravencms\Model\HtmlSnippet\Repository; -use Dravencms\Model\Article\Entities\Article; -use Dravencms\Model\Article\Entities\Group; use Dravencms\Model\HtmlSnippet\Entities\HtmlSnippet; use Kdyby\Doctrine\EntityManager; use Nette; @@ -102,7 +100,7 @@ public function getOneByIdAndActive($id) /** * @param array $parameters - * @return Article + * @return HtmlSnippet */ public function getOneByParameters(array $parameters) { diff --git a/src/Dravencms/Model/HtmlSnippet/Repository/HtmlSnippetTranslationRepository.php b/src/Dravencms/Model/HtmlSnippet/Repository/HtmlSnippetTranslationRepository.php index 61f5a14..988da43 100644 --- a/src/Dravencms/Model/HtmlSnippet/Repository/HtmlSnippetTranslationRepository.php +++ b/src/Dravencms/Model/HtmlSnippet/Repository/HtmlSnippetTranslationRepository.php @@ -5,14 +5,10 @@ namespace Dravencms\Model\HtmlSnippet\Repository; -use Dravencms\Model\Article\Entities\Article; -use Dravencms\Model\Article\Entities\ArticleTranslation; -use Dravencms\Model\Article\Entities\Group; use Dravencms\Model\HtmlSnippet\Entities\HtmlSnippet; use Dravencms\Model\HtmlSnippet\Entities\HtmlSnippetTranslation; use Kdyby\Doctrine\EntityManager; use Nette; -use Gedmo\Translatable\TranslatableListener; use Dravencms\Model\Locale\Entities\ILocale; class HtmlSnippetTranslationRepository