/**
  * @param ContentBlock $contentBlock
  * @param Locale $locale
  */
 public function __construct(ContentBlock $contentBlock, Locale $locale)
 {
     parent::__construct('SELECT i.id, i.revision_id, i.title, UNIX_TIMESTAMP(i.edited_on) AS edited_on, i.user_id
          FROM content_blocks AS i
          WHERE i.status = :archived AND i.id = :id AND i.language = :language
          ORDER BY i.edited_on DESC', ['archived' => ContentBlockStatus::archived(), 'language' => $locale, 'id' => $contentBlock->getId()]);
 }
 /**
  * @param CopyContentBlocksToOtherLocale $copyContentBlocksToOtherLocale
  *
  * @return ContentBlock
  */
 public function handle(CopyContentBlocksToOtherLocale $copyContentBlocksToOtherLocale)
 {
     $fromLocaleContentBlocks = (array) $this->contentBlockRepository->findBy(['locale' => $copyContentBlocksToOtherLocale->fromLocale, 'status' => ContentBlockStatus::active()]);
     $id = $this->contentBlockRepository->getNextIdForLanguage($copyContentBlocksToOtherLocale->toLocale);
     array_map(function (ContentBlock $contentBlock) use($copyContentBlocksToOtherLocale, &$id) {
         $copyContentBlocksToOtherLocale->extraIdMap[$contentBlock->getExtraId()] = $this->getNewExtraId();
         $otherLocaleContentBlock = ContentBlock::create($id++, $contentBlock->getUserId(), $copyContentBlocksToOtherLocale->extraIdMap[$contentBlock->getExtraId()], $copyContentBlocksToOtherLocale->toLocale, $contentBlock->getTitle(), $contentBlock->getText(), $contentBlock->isHidden(), $contentBlock->getTemplate());
         $this->contentBlockRepository->add($otherLocaleContentBlock);
     }, $fromLocaleContentBlocks);
 }
 /**
  * @param string $status
  * @param AbstractPlatform $platform
  *
  * @return ContentBlockStatus
  */
 public function convertToPHPValue($status, AbstractPlatform $platform)
 {
     return ContentBlockStatus::fromString($status);
 }
Beispiel #4
0
 public function archive()
 {
     $this->status = ContentBlockStatus::archived();
 }
 /**
  * @param int $id
  * @param Locale $locale
  *
  * @return ContentBlock|null
  */
 public function findOneByIdAndLocale($id, Locale $locale)
 {
     return $this->findOneBy(['id' => $id, 'status' => ContentBlockStatus::active(), 'locale' => $locale]);
 }
 /**
  * @param Locale $locale
  */
 public function __construct(Locale $locale)
 {
     parent::__construct('SELECT i.id, i.title, i.hidden
          FROM content_blocks AS i
          WHERE i.status = :active AND i.language = :language', ['active' => ContentBlockStatus::active(), 'language' => $locale]);
 }