culttt / cribbb

http://cribbb.com
449 stars 99 forks source link

I don't understand how you're resolving your dependencies #11

Closed keithmifsud closed 9 years ago

keithmifsud commented 9 years ago

Philip,,

You're not resolving your dependencies using a service provider. How are they resolved if they are?

If you're not using the IoC, how are you resolving and implementing the interfaces? Am I missing something?

philipbrown commented 9 years ago

Yeah that's right, I'm mostly not resolving stuff out of the IoC Container yet because I've only written the unit tests so far. Once I start writing the Controllers and wiring stuff together I'll be resolving stuff out of the Container.

So you're right, I'm not at the minute, but I will need to.

Hope that makes sense :smile:

keithmifsud commented 9 years ago

Thanks for the prompt answer Phil :)

I was interested to see how you're resolving the object interfaces such as which implementation of the UUID to use etc.. Will these be done using a service provider? Don't worry about it if this is way too early and you haven't though about it yet.

philipbrown commented 9 years ago

Yeah that's exactly what I'll be doing :)

However for UUID's in particular I'm just going to be depending on https://github.com/ramsey/uuid

keithmifsud commented 9 years ago

It's possible that I'm missing something here...

The User private constructor requires the $id to be a UserId but neither the static resister nor the UserRegister Service are building the Uuid object or generating the Uuid string. Also since the service is not expecting a Uuid object I don't think that it's generated in Application layers.

philipbrown commented 9 years ago

The UserId is created from the repository https://github.com/yellowflag/cribbb/blob/master/app/Infrastructure/Repositories/UserDoctrineORMRepository.php#L41

keithmifsud commented 9 years ago

HI Philip,

Sorry for the long thread of questions but I'm still struggling to understand this particular process.

The service creates the User object: $user = User::register($id, $email, $username, $password);

This static method needs a UserId: public static function register(UserId $userId, Email $email, Username $username, HashedPassword $password) { $user = new User($userId, $email, $username, $password); return $user; }

But the repository is triggered afterwards in the service: $this->userRepository->add($user);

So how is the Uuid generated from the repository to be sent to the User object since botht he static and the constructor require an instance of the Uuid?

philipbrown commented 9 years ago

The UserId is requested from the nextIdentity() method of the repository here https://github.com/yellowflag/cribbb/blob/master/app/Domain/Services/Identity/RegisterUserService.php#L55

keithmifsud commented 9 years ago

Lol... I didn't see that :)

Thanks.

philipbrown commented 9 years ago

No problem :smile: Give me a shout if anything else doesn't make sense!