public static function updateBlockRepeaters() { foreach (self::$_repeaterBlocks as $repeater => $repeaterBlocks) { $arrayList = []; foreach ($repeaterBlocks as $repeaterBlock) { $arrayList[] = self::$_allBlocks[$repeaterBlock]->id; } $implodedList = implode(',', $arrayList); if (empty(self::$_databaseRepeaterBlocks[self::$_allBlocks[$repeater]->id])) { $newBlockRepeater = new BlockRepeater(); $newBlockRepeater->block_id = self::$_allBlocks[$repeater]->id; $newBlockRepeater->blocks = $implodedList; $newBlockRepeater->save(); } elseif (self::$_databaseRepeaterBlocks[self::$_allBlocks[$repeater]->id]->blocks != $implodedList) { self::$_databaseRepeaterBlocks[self::$_allBlocks[$repeater]->id]->blocks = $implodedList; self::$_databaseRepeaterBlocks[self::$_allBlocks[$repeater]->id]->save(); } } }
/** * Get search text from repeater blocks * @param null|string $content * @return null|string */ public function generateSearchText($content) { $searchText = ''; $repeaterRows = PageBlockRepeaterData::loadRepeaterData($content, $this->_block->getVersionId()); $repeaterBlocks = BlockRepeater::getRepeaterBlocks($this->_block->id); foreach ($repeaterRows as $rowId => $repeaterRow) { foreach ($repeaterBlocks as $blockId => $repeaterBlock) { if (($blockContent = array_key_exists($blockId, $repeaterRow) ? $repeaterRow[$blockId] : null) !== null) { $block = Block::preloadClone($blockId)->setRepeaterData($this->_block->getRepeaterId(), $this->_block->getRepeaterRowId())->setPageId($this->_block->getPageId()); if ($block->exists && $block->search_weight > 0) { $blockSearchText = $block->getTypeObject()->generateSearchText($blockContent); $searchText .= $blockSearchText !== null ? $blockSearchText . "\n" : ''; } } } } return parent::generateSearchText($searchText); }