This extension will save you much, much time. Time that you will have to spend on other things. With your children, your wife or your mother-in-law. In other words: You might run out of excuses.
If you have any doubts whether you can cope with this, you should NOT install nnhelpers. We are not responsible for any side effects that may occur in your developer life as a result of the time gained.
What does it do?¶
Let it (nn)help you, whenever things seem to get more compliated that they should be.
Let’s look at a few examples:¶
Let’s say you have built an upload form. The user can upload an image in the frontend. You would like to have the image as FAL on a model.
Sounds like an everyday task, doesn’t it? So: Let’s ask Google. After countless variations of search phrases, you land on a promising doc at docs.typo3.org.
You work your way through many lines of information and end up with this statement: Not our business. Take care of it yourself, or steal it from Helmut. You then spend then the next 30 minutes with lovely Helmut. Enjoying beautiful source codes. And searching desperately for the little snippet you need for your project.
I don’t know how long it took you to solve this task the first time. For us it was about four hours. We were in Typo3 version 6 at that time. When the 7 LTS was released, we searched again because some things changed in the core. When version 8 LTS was released, it was again almost 2 hours. And then the adaption had to be done over and over again for ALL our extensions that implemented a file upload from the frontend context.
This is a nightmare and time that seems kind of pointless. I prefer to spend this time - without batting an eye - with my choleric mother-in-law.
How would we solve this task today?
setInModel()sounds pretty much like the thing we’re looking for.
@inject? Just a no-brainer ONELINER?
\nn\t3::Fal()->setInModel( $model, 'fieldname', 'path/to/image.jpg' );
foreach. But wait… there’s more!
\nn\t3::Fal()->setInModel( $model, 'fieldname', ['image-1.jpg', 'image-2.jpg'] );
\nn\t3::Fal()->setInModel( $member, 'fieldname', ['publicUrl'=>'01.jpg', 'title'=>'Titel', 'description'=>'...'] );
\nn\t3::Fal()->setInModel( $member, 'fieldname', [ ['publicUrl'=>'01.jpg', 'title'=>'Titel', 'description'=>'...'], ['publicUrl'=>'02.jpg', 'title'=>'Titel', 'description'=>'...'], ]);