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

Method name collisions #4

Closed
barnabaskecskes opened this issue Nov 29, 2019 · 7 comments
Closed

Method name collisions #4

barnabaskecskes opened this issue Nov 29, 2019 · 7 comments

Comments

@barnabaskecskes
Copy link

If I use the traits from this package and the dcasia/conditional-container package as the documentations suggest, the latter trait's methods will be ignored therefore these packages won't play ball with each other. What is your suggestion?

@milewski
Copy link
Member

Hi @barnabaskecskes , unfortunately, Nova doesn't provide any way for a package to hook into its "life cycle" so in order to archive some functionality we need to "override" some methods that nova will call on its request lifecycle.. but you still can use both packages together by creating subclasses and extending them.. for example:

class WithJsonWrapperField extends Resource {

     use HasJsonWrapper;

}
class WithConditionalContainerField extends WithJsonWrapperField {
    
     use HasConditionalContainer;

}
class YourResourceClass extends WithConditionalContainerField
{
    public function field()
    {
        return [
            ConditionalContainer::make([
                JsonWrapper::make(...)
            ])
        ];
    }
}

@barnabaskecskes
Copy link
Author

Thanks for the response. I think this is exactly the same as just dropping the HasJsonWrapper trait and using it like below (which I have ended up doing in my case), but please correct me if I'm wrong?

class MyResourceClass
{
	use HasConditionalContainer;

	public function field()
    {
        return [
            ConditionalContainer::make([
                JsonWrapper::make(...)
            ])
        ];
    }
}

@milewski
Copy link
Member

milewski commented Nov 29, 2019

Without the HasJsonWrapper, your resource won't display correctly on details view

What that trait does is, when you are on the detail views it merge all its given fields into a your main fields array, so it display as if there wasn't any json wrapper at all, if you remove it nova will try to render it, but there isn't any detail field definition for json wrapper, so all your nested fields I'll be gone on details view...

@bolechen
Copy link
Contributor

bolechen commented Dec 26, 2019

i try to work the whole afternoon, but not works fine together :(
could you give more help?

very thx. this is my test code.

Nova.zip

@milewski
Copy link
Member

milewski commented Dec 26, 2019

Maybe something has changed in the latest version of nova, the project I use both packages together uses nova 2.5 so I will need some time to figure out what's wrong, your example looks correct

@bolechen
Copy link
Contributor

bolechen commented Apr 1, 2020

any news for this? @milewski thx

@u12206050
Copy link

Also would like a fix for this, using nova version 3.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants