Backend\Modules\ContentBlocks\Entity\ContentBlock::create PHP Method

create() public static method

public static create ( integer $id, integer $userId, integer $extraId, string $locale, string $title, string $text, boolean $isHidden, string $template = self::DEFAULT_TEMPLATE ) : self
$id integer
$userId integer
$extraId integer The id of the module extra
$locale string
$title string
$text string
$isHidden boolean
$template string
return self
    public static function create($id, $userId, $extraId, $locale, $title, $text, $isHidden, $template = self::DEFAULT_TEMPLATE)
    {
        return new self($id, $userId, $extraId, $template, $locale, $title, $text, $isHidden, ContentBlockStatus::active());
    }

Usage Example

 /**
  * @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);
 }
All Usage Examples Of Backend\Modules\ContentBlocks\Entity\ContentBlock::create