symfony - symfony2 and Doctrine2 - upload as a service -
i'm learning symfony2 , need advice. have 2 entities, first entity "issue" has onetomany relationship second entity "attachment". when posting issue form uploading child attachments, works hunky-dory :) want turn upload solution service , that's i'm getting confused. uploads processed in attachment model , controller reads follows :
if ($editform->isvalid()) { $em->persist($entity); $em->flush(); .... from understand service can accessed controller using "get" method because not process attachments in controller , never instantiate "attachment" model controller how pass upload service? instantiating within attachment entity construct appears defeat object of exercise doesn't it?
forgive me if talking rubbish. idiot friendly guidance appreciated.
edit:: further feedback, should uploads treated service processed in controller or behaviour associated model? way jump.
i'm doing similar in zf2 - use controller still process , receive upload, use service extract uploads, register them database etc.
i name of file it's temporarily uploaded , pass through service (i.e /tmp/up2029398393). moves it's supposed be, creates entity , persist & flush object
Comments
Post a Comment