Skip to content

Conversation

@miclf
Copy link
Contributor

@miclf miclf commented Dec 8, 2014

As suggested by @jasonlewis in #6500.

@GrahamCampbell GrahamCampbell changed the title Allow to set default crypt cost factor (see #6500) [4.2] Allow Setting The Default Crypt Cost Factor Dec 8, 2014
@jasonlewis
Copy link
Contributor

As you mentioned in the referenced issue the service provider will probably need to be changed as well so that it's a shared binding. Otherwise you won't be able to globally set the cost factor.

@miclf
Copy link
Contributor Author

miclf commented Dec 9, 2014

Never mind, I think it’s not needed. The Closure is currently bound via bindShared:

/**
* Register the service provider.
*
* @return void
*/
public function register()
{
    $this->app->bindShared('hash', function() { return new BcryptHasher; });
}

Looking at the IoC, what I understand from this is: the Closure is wrapped into another one and is executed only once because its return value is stored as a static property of the outer, shared Closure (see Container.php#L203). So I guess the IoC always gives the same instance of the Hasher.

Does this sound right?

taylorotwell added a commit that referenced this pull request Dec 15, 2014
[4.2] Allow Setting The Default Crypt Cost Factor
@taylorotwell taylorotwell merged commit 1a2ef4a into laravel:4.2 Dec 15, 2014
@miclf miclf deleted the patch-2 branch December 15, 2014 20:08
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.

4 participants