Closed hbugdoll closed 8 months ago
Ok, the reason is clear.
https://github.com/luyadev/luya-module-cms/blob/496cebc789658537381825958f8ae72524b4f6e7/src/base/NavItemType.php#L33-L36 returns the navItem
only for the active page version (with nav_item_type_id
).
I tried
public function getNavItem()
{
return $this->hasOne(NavItem::class, ['id' => 'nav_item_id'])->where(['nav_item_type' => static::getNummericType()]);
}
in the manner hasOne(..., PK => FK)
like in NavItemPage::getForceNavItem()
.
It works and unit tests are running successfully.
@nadar If you agree, I could provide a PR.
@nadar If you agree, I could provide a PR.
I am now convinced that this must be fixed.
But why not use getEnvOption('pageObject')->forcedNavItem
instead of getEnvOption('pageObject')->navItem
?
The getEnvOption('pageObject')
is a misleading concept anyhow, but introduced back in the days. It would be so much better to have $this->page-><NavItemPage>
so the IDE knows all possible methods to use, instead of array keys you have to lookup on guides. But thats another story :-)
Thanks @nadar for reply in busy times.
But why not use
getEnvOption('pageObject')->forcedNavItem
instead ofgetEnvOption('pageObject')->navItem
?
Yes, that would be a possibility in my case.
But in respect of the absent type check in getEnvOption('pageObject')->forcedNavItem
I would prefer the straightforward solution...
The
getEnvOption('pageObject')
is a misleading concept anyhow, but introduced back in the days. It would be so much better to have$this->page-><NavItemPage>
so the IDE knows all possible methods to use, instead of array keys you have to lookup on guides. But thats another story :-)
Yeah, indeed!
The
getEnvOption('pageObject')
is a misleading concept anyhow, but introduced back in the days. It would be so much better to have$this->page-><NavItemPage>
so the IDE knows all possible methods to use, instead of array keys you have to lookup on guides. But thats another story :-)
Ok, let's go 🚀
What steps will reproduce the problem?
getEnvOption('pageObject')
inside of a page block.What is the expected result?
What do you get instead?
getEnvOption('pageObject')->navItem
is missing.It seems thatNavItemPage::copyBlocks()
doesn't depp-copied the page's blocks.Edit: The issue is not only related to new page versions, but to inactive page versions.
Additional infos