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

Fix Callables for Extenders #2423

Merged
merged 9 commits into from
Nov 9, 2020
Merged

Fix Callables for Extenders #2423

merged 9 commits into from
Nov 9, 2020

Conversation

askvortsov1
Copy link
Sponsor Member

Fixes #2401, mostly minor cleanup and adding tests to prevent regressions.

Copy link
Member

@clarkwinkelmann clarkwinkelmann left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not tested locally. Looks good, just one comment.

src/Extend/Model.php Outdated Show resolved Hide resolved
Comment on lines +17 to +21
$callback = function () use ($container, $callback) {
$callback = $container->make($callback);

return call_user_func_array($callback, func_get_args());
};
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why not just $callback = $container->make($callback); ?

Copy link
Sponsor Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Clark pointed out in #2176 (comment) that $callback = $container->make($callback); means that the callback will be resolved every time the site boots, even if its not needed for that request.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

my bad, didn't see that..

Copy link
Sponsor Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do agree it's a bit ugly, if there are simpler ways to do it, I'm all ears. But at least with the util, it's abstracted away so if we need to change it, that should be easy.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it looks good to me 🤷

Copy link
Member

@clarkwinkelmann clarkwinkelmann left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking good with the helper! Some more comments.

src/Extend/Model.php Outdated Show resolved Hide resolved
src/Foundation/ContainerUtil.php Outdated Show resolved Hide resolved
@askvortsov1
Copy link
Sponsor Member Author

@clarkwinkelmann fixed! Any thoughts on naming for the util?

Copy link
Member

@SychO9 SychO9 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me!

@askvortsov1 askvortsov1 merged commit 47d2eee into master Nov 9, 2020
@askvortsov1 askvortsov1 deleted the as/fix-callables-extenders branch November 9, 2020 02:36
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

Successfully merging this pull request may close these issues.

All callable-based extenders should accept and resolve invoke-able classes
4 participants