Hi,
just my 2 cents...
I had the requirement to write classes which will work without the frameworks
mvc.
The strategy I used was to create a kind of layer which gets the
data from the frameworks mvc injected. Something like
$myClass = new \MyClass('otherObjects', $form, $request->getPost(), $etc);
Then I was able to use my classes in our other projects which doesn´t use
the zf mvc. In MyClass I do the business logic and set a status which I fetch
later.
switch($myClass->getStatus())
{
case 'this';
// do something
break;
case 'that':
// do something other, forward to login, whatever
break;
}
Only thing I have to do id to deliver the library with it.
Greetings
Marc
-----Ursprüngliche Nachricht-----
Von: luk [mailto:[email protected]]
Gesendet: Montag, 1. Oktober 2012 16:36
An: [email protected]
Betreff: [fw-general] Re: Business logic inside controller
Webdevilopers wrote
> I have senn a lot of examples for ZF form handling already like this one:
> Zend Framework 2 : Create Simple Upload Form with File Validation
> <http://samsonasik.wordpress.com/2012/08/31/zend-framework-2-creating-upload-form-file-validation/>
>
>
> The business logic (handling file upload etc.) takes place inside the
> action of the controller:
>
> Regarding the "fat model, skinny controller" strategy are these examples
> for keeping it simple to understand the sequence of logic? Isn't it best
> practice to create a service class to handle the whole process to make the
> code re-usable and keep the controller skinny?
>
> What do you think?
It's entirely up to you. I would use a strategy based on the size of your
application. If your application is relatively small and has got only few
controllers it is ok to have logic inside them. If it's significantly larger
then I would use Service layer.
-----
Cheers,
--
Luke Mierzwa
--
View this message in context:
http://zend-framework-community.634137.n4.nabble.com/Business-logic-inside-controller-tp4657256p4657267.html
Sent from the Zend Framework mailing list archive at Nabble.com.
--
List: [email protected]
Info: http://framework.zend.com/archives
Unsubscribe: [email protected]
--
List: [email protected]
Info: http://framework.zend.com/archives
Unsubscribe: [email protected]