Skip to content

add getFiles()#32

Merged
lentex merged 2 commits intokarriereat:masterfrom
Chris53897:patch-1
Feb 19, 2025
Merged

add getFiles()#32
lentex merged 2 commits intokarriereat:masterfrom
Chris53897:patch-1

Conversation

@Chris53897
Copy link
Contributor

this makes it easier to cleanup after creation.
I want to delete all files after merge

@lentex
Copy link
Member

lentex commented Feb 18, 2025

I'm fine with the proposed addition, but I don't know how a getter helps you to "cleanup after creation". there is a reset method for that. do you still want to go ahead with that?

@Chris53897
Copy link
Contributor Author

My code looks like this:
i use symfony, so this should be left in userland.

$pdfMerge = new PdfMerge();
            $fs = new Filesystem();
            $filenames = [];

            # Combine
            foreach($files as $key => $file)
            {
                $filename = $tempPath.uniqid('', true).'_'.$key;
                $filenames[] = $filename;
                $fs->dumpFile($filename, $file);
                $pdfMerge->add($filename);
            }

            $merged = $pdfMerge->merge($tempPath.$filenameOutput);
            ...

            # cleanup
            foreach($filenames as $filename)
            {
                $fs->remove($filename);
            }

new

$pdfMerge = new PdfMerge();
            $fs = new Filesystem();

            # Combine
            foreach($files as $key => $file)
            {
                $filename = $tempPath.uniqid('', true).'_'.$key;
                $fs->dumpFile($filename, $file);
                $pdfMerge->add($filename);
            }

            $merged = $pdfMerge->merge($tempPath.$filenameOutput);
            ...

            # cleanup
            foreach($pdfMerge->getFiles() as $filename)
            {
                $fs->remove($filename);
            }

Copy link
Member

@lentex lentex left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add an entry in the changelog.md file as well

@Chris53897
Copy link
Contributor Author

Chris53897 commented Feb 19, 2025

done. Please adjust changelog entry to your needs

@lentex lentex merged commit 52d202e into karriereat:master Feb 19, 2025
4 checks passed
@Chris53897 Chris53897 deleted the patch-1 branch February 19, 2025 08:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants