Skip to content

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

@travisbotello

Description

@travisbotello

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions