Closed artur-gajewski closed 11 years ago
Can we first have some kind of documentation that clearly shows what the service layer and an overall system architect looks like? So that we have a generally agreed system design.
Services are defined in bundle/Resource/config/services.yml and reside in bundle/Service/ ?
bundle/Resources/... but yeah.
Maybe we could use the ACMEDemoBundle to create a proof of concept example on how we could create and utilize the service layer for handling, for example, form requests in a nicely fashion.
I'll grab something to eat and then I could create an example on how I see we could work it out.
You guys come up with an architecture, I trust you guys as to what the outcome is going to be, so go ahead and add the ACMEDemoBundle which we will use as a guideline.
I think the use of lambdas makes it very hard to read with little gain.
I have made a suggestion here: http://fixthatcode.com/entry/19/show
I agree, that lambdas make the logic tedious to follow in code. In principle, trying to keep methods thin and classes do just one thing is a good idea. @rdohms solution looks good to me.
It seems like rdohms' suggestion is clearer to read and follow, so how about this change in the DemoBundle? https://github.com/YouHighFiveMe/youhighfiveme/blob/mediator/src/Portal/DemoBundle/Controller/DefaultController.php
Further, I suggest defining mediateForm as abstract, because the precise implementation propably varies between forms. More generally, one service might handle several forms, so even this may not suffice, and we need to define several mediators. This sounds like there's not a simple way to abstract it.
I say we keep the name processForm() but use rdohms model otherwise. Let's keep it simple and if we later need to change then we do so. We have used processForm() successfully in two projects now so I believe we can start with it.
We don't have to use lambdas and such. We can keep it simple. ;)
The BaseController needs to be moved to another place; either under Portal\MainBundleController or perhaps Portal\Component\Controller namespace.
EventController now has processForm() function that binds data to the form and then validates it.
Also implemented services for event and highfives.
Instead of putting a lot of code into controllers, use a service layer that contains the business logic. Controllers should delegate the task to a service instead.