Programatically create download file for current user

Created on 18 April 2023, almost 2 years ago

I'm using the FillPDF module to create a downloadable file for purchase. The PDF will be filled by data from a custom Checkout Pane.

Can I then, within my module, create a link to the file that ONLY the user who completed the order can have access to? For any other user, access is denied.

The link to the file will go into a custom email as a part of my module, and also be available on the User's account page as per normal.

I think I'll need something like:

use Drupal\file\FileInterface;
use Drupal\commerce_file\LicenseFileManagerInterface;
use Drupal\commerce_license\Entity\LicenseInterface;
use Drupal\commerce_file\FileDownloadController;

And then call which function to create access to the file for the current user???

Thanks,
Glenn

💬 Support request
Status

Active

Version

2.0

Component

Code

Created by

🇳🇿New Zealand glennnz

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.71.5 2024