Skip to content

[5.8] added $params argument to resolve helper - #28020

Merged
taylorotwell merged 2 commits into
laravel:5.8from
yamenarahman:5.8
Mar 26, 2019
Merged

[5.8] added $params argument to resolve helper#28020
taylorotwell merged 2 commits into
laravel:5.8from
yamenarahman:5.8

Conversation

@yamenarahman

Copy link
Copy Markdown
Contributor

$api = resolve('HelpSpot\API'); is an alias for $api = $this->app->make('HelpSpot\API');

So, may $api = resolveWith('HelpSpot\API', ['id' => 1]);
be an alias for $api = $this->app->makeWith('HelpSpot\API', ['id' => 1]);

@driesvints

Copy link
Copy Markdown
Member

Can't we just add the , array $params = [] part to the resolve function instead? Would rather not see more helpers be added.

@driesvints

Copy link
Copy Markdown
Member

Btw, you can already do this with

$api = app('HelpSpot\API', ['id' => 1]);

@driesvints driesvints changed the title added resolveWith helper [5.8] added resolveWith helper Mar 26, 2019
@yamenarahman

Copy link
Copy Markdown
Contributor Author

Hmm, Thanks.

@yamenarahman

yamenarahman commented Mar 26, 2019

Copy link
Copy Markdown
Contributor Author
function resolve($name, array $params = []) 
{
    return app($name, $params);
}

Should it be like that?

@yamenarahman yamenarahman changed the title [5.8] added resolveWith helper [5.8] added $params argument to resolve helper Mar 26, 2019
Comment thread src/Illuminate/Foundation/helpers.php Outdated
@yamenarahman

Copy link
Copy Markdown
Contributor Author

@36864 resolve is already an alias for app.

@Miguel-Serejo

Copy link
Copy Markdown

Sorry, jumped the gun with my previous comment.

I still think this type of alias helpers should just be removed, but no harm in just making it closer to the helper it's aliasing I guess.

@devcircus

devcircus commented Mar 26, 2019

Copy link
Copy Markdown
Contributor

A little history:
Originally this helper accepted parameters, but for a brief time, the container was changed to not have this ability. So parameters were removed from the “app” and “resolve” helpers in #17060. A few months later parameters were brought back in #18271, so parameters were added back to the “app” helper in #18320. Somehow “resolve” just got left out of those changes.

We’ve made it 2 years without anyone asking why.

@taylorotwell
taylorotwell merged commit f852b97 into laravel:5.8 Mar 26, 2019
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.

5 participants