goldsky / FileDownload-R

FileDownload snippet for MODX revolution
12 stars 7 forks source link

Running the snippet in modRestController causing error because active resource is required #63

Open travisbotello opened 5 years ago

travisbotello commented 5 years ago

I am generating JSON objects using modRestController. Inside controller I'd like to use FileDownload-R snippet. I am calling it via runSnippet() to add the hashed download links to my JSON objects. This is failing with:

2019/02/08 16:12:06 [error] 4734#4734: *37304 FastCGI sent in stderr: "PHP message: PHP Fatal error:  Uncaught Error: Call to a member function get() on null in /web/core/components/filedownloadr/model/filedownloadr/filedownloadr.class.php:1383

The error line in question is:

$url = $this->modx->makeUrl($this->modx->resource->get('id'), $ctx, @implode('&', $args));

The problem is that in modRestController there is no active/current resource that could be used for makeUrl. Is it possible to add a property to define a custom resource/id to generate the link for?