*Step 1.*
I develop modules for my finance application. I use the following base
conceptions - modules, service layer, data mapper, domain-driven model. For
example application uses only one "vendor/hmrUser" module (signIn, signOut,
signUp) and he has the following structure:
- Controller/UserController.php
- Entity/User.php
- Entity/UserInterface.php
- Mapper/User.php
- Mapper/UserInterface.php
- Service/User.php
/Presentation layer (controller) doesn't know about data mappers and domain
model. Presentation layer works only with a service layer. Service layer
checks data and knows about mappers and domain models (entity). Domain model
doesn't know about data mappers and service layer and knows about other
domain models./

*Step 2.*
After a while it is necessary to add the "vendor/hmrOrganization" module in
my application. "HmrOrganization" module can work with (step 3) *OR* without
"HmrUser" module (soft dependence between modules). User and organization
have "many-many" the relation in DB (user, organization, user_organization
tables). Without "HmrUser" module the "HmrOrganization" has the following
structure:
- Controller/OrganizationController.php
- Entity/Organization.php
- Entity/OrganizationInterface.php
- Mapper/Organization.php
- Mapper/OrganizationInterface.php
- Service/Organization.php

*Step 3.*
Now my application has two modules which don't interact with each other. But
customer want new feature - when he create new organization he can select
persons who work in her. 

*Solutions:*
I think over the following solutions:
1. Add new functionality in User and Organization module (e.g. add in both
modules "getOrganizationsByUserId()", "getUsersByOrganizationId()" in user
services, necessary mappers, collections in entities). But this solution is
bad because "User" module is used in other application without such
functions (base module).
2. Add the following interfaces in the "Organization" module:
- Entity/User.php (class User extends \HmrUser\Entity\User implements
UserInterface { /* realization */ } );
- Entity/UserInterface.php (getOrganizations(), addOrganization(),
removeOrganization());
- Mapper/User.php (class User extends \HmrUser\Mapper\User implements
UserInterface { /* realization */);
- Mapper/UserInterface.php (getOrganizationsByUserId()).
- may be Service\User.php and Service\UserInterface.php;
3. It is similar to point 2, but new interfaces/classes a create in new
"UserOrganization" module with 2 services - User
(getOrganizationByUserId()), Organization (getUsersByOrganizationId()).

*Questions:*
- what do you think of it?
- your solutions?
- what decision the most correct?
- any information on this subject?
- how and where i must add getOrganizationByUserId() service method?
-- add in HmrUser\Service\User?
-- add in HmrOrganization\Service\Organization?
-- craate and add in HmrOrganization\Service\User?
-- create and add in HmrOrganization\Service\User and redefine
HmrUser\Service\User via IoC?
-- add HmrUserOrganization\Service\User (getUsersByOrganizationId() in
HmrUserOrganization\Service\Organization)?

--------------------------------------

Thanks and sorry for my poor English, i hope you understand me)



--
View this message in context: 
http://zend-framework-community.634137.n4.nabble.com/zf2-modules-interaction-user-organization-module-tp4659068.html
Sent from the Zend Framework mailing list archive at Nabble.com.

-- 
List: [email protected]
Info: http://framework.zend.com/archives
Unsubscribe: [email protected]


Reply via email to