I've been tidying up my classes, moving a lot of stuff from controllers to models and, so far, it's all been quite intuitive. However, there's one controller I'm really stuck on. This one involves uploads, though they can be several different types. I'll call the model Record because the actual name would be meaningless.
A record can involve exactly one of several file resources. When it's created, the controller can expect, eg. an image, an audio file, a video, or some text (from a textarea). The latter is saved as text file while the others are--big surprise--uploaded to the filesystem. If it's an image, it's resized, if necessary, to maximum width/height. Upon successful save, the user is presented with a view that allows cropping to create a thumbnail. If it's any of the other types, the record is saved after various tasks are performed (eg, grab video frames with FFmpeg) and then the user is presented with an opportunity to upload a thumbnail, after which the cropper view is displayed. So, there are several different behaviors or components that are necessary here: image resizing, thumbnail cropping, text file creation, video fiddling, etc. And, there's a difference in redirects if it's an image or not. Using components, I can't seem to get this all pulled together without creating ridiculously convoluted controller actions. Given that I need both add and edit, plus the same for admin routes, this gets stupid fairly quick. I'd like to move all this to behaviors (in spite of the gut feeling I can't shake that this sort of thing is much more "component-like") but I can't decide how to proceed. One of my hangups is trying to figure out how to propagate errors from the behavior back to the controller. The way I see it, the controller won't know anything about *what* the problem was, only that $this->Record->Save() failed for some reason. What am I missing here? How should I be approaching this? --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~----------~----~----~----~------~----~------~--~---
