Skip to content

Commit

Permalink
Cleanup + migration to Nette\SmartObject + new dravencms\locale
Browse files Browse the repository at this point in the history
  • Loading branch information
Salamek committed Jan 4, 2018
1 parent e40ed32 commit e565948
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;

/**
Expand All @@ -47,6 +44,7 @@ class HtmlSnippetGrid extends BaseControl
/** @var EntityManager */
private $entityManager;

/** @var ILocale */
private $currentLocale;

/**
Expand All @@ -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;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -19,7 +19,7 @@ class Detail extends BaseControl
/** @var ICmsActionOption */
private $cmsActionOption;

/** @var CurrentLocale */
/** @var ILocale */
private $currentLocale;

/** @var HtmlSnippetTranslationRepository */
Expand All @@ -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
)
Expand All @@ -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__);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;

Expand All @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -102,7 +100,7 @@ public function getOneByIdAndActive($id)

/**
* @param array $parameters
* @return Article
* @return HtmlSnippet
*/
public function getOneByParameters(array $parameters)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit e565948

Please sign in to comment.