Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add missing env informations to block #401 #403

Merged
merged 2 commits into from
Feb 5, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 24 additions & 4 deletions src/models/NavItemPage.php
Original file line number Diff line number Diff line change
Expand Up @@ -432,9 +432,27 @@ public static function getPlaceholder($placeholderVar, $prevId, NavItemPage $nav
->all();

$data = [];
$i = 0;
$equalIndex = 1;
$blocksCount = count($nav_item_page_block_item_data);

foreach ($nav_item_page_block_item_data as $blockItem) {
$item = self::getBlockItem($blockItem, $navItemPage);
foreach ($nav_item_page_block_item_data as $key => $blockItem) {
$i++;
$prev = $key - 1;
$next = $key + 1;
$prevIsEqual = array_key_exists($prev, $nav_item_page_block_item_data) && $blockItem['block_id'] == $nav_item_page_block_item_data[$prev]['block_id'];

$envOptions = [
'index' => $i,
'itemsCount' => $blocksCount,
'isFirst' => ($i == 1),
'isLast' => ($i == $blocksCount),
'isPrevEqual' => $prevIsEqual,
'isNextEqual' => array_key_exists($next, $nav_item_page_block_item_data) && $blockItem['block_id'] == $nav_item_page_block_item_data[$next]['block_id'],
'equalIndex' => (!$prevIsEqual) ? ($equalIndex = 1) : ($equalIndex++)
];

$item = self::getBlockItem($blockItem, $navItemPage, $envOptions);
if ($item) {
$data[] = $item;
}
Expand All @@ -451,7 +469,7 @@ public static function getPlaceholder($placeholderVar, $prevId, NavItemPage $nav
* @param integer $blockId
* @return array
*/
public static function getBlockItem(NavItemPageBlockItem $blockItem, NavItemPage $navItemPage)
public static function getBlockItem(NavItemPageBlockItem $blockItem, NavItemPage $navItemPage, array $envOptions = [])
{
// if the block relation could be found, return false.
if (!$blockItem->block) {
Expand All @@ -471,7 +489,9 @@ public static function getBlockItem(NavItemPageBlockItem $blockItem, NavItemPage

$blockObject->setVarValues((empty($blockValue)) ? [] : $blockValue);
$blockObject->setCfgValues((empty($blockCfgValue)) ? [] : $blockCfgValue);

foreach ($envOptions as $envKey => $envValue) {
$blockObject->setEnvOption($envKey, $envValue);
}
$placeholders = [];

foreach ($blockObject->getConfigPlaceholdersByRowsExport() as $rowKey => $row) {
Expand Down
Loading