I've done some further debugging, but haven't found a solution so far.
I included the working snippet into the plugin with the code:
$resourceID = $resource->id ;
$modx->runsnippet('workingsnippet', array('x' => $resourceID));
It still won't work of course, but the nginx-log reveals what's going on:
2018/12/12 14:52:57 [error] 18924#18924: *16402 FastCGI sent in stderr: "PHP message: PHP Fatal error: Uncaught Error: Call to a member function get() on null in /var/www/modx/cache/configiedereenbenieuwd/includes/elements/modsnippet/25.include.cache.php:29
Snippet 25 is none other than 'ImagePlus' and line 29 in that snippet is
$docid = $modx->getOption('docid', $scriptProperties, $modx->resource->get('id'), true);
Apparently, modx fails while executing '$modx->resource->get('id')', the default value for '$docid'.
But why is it taking the default value if '$docid' is not empty???
Why is it failing when executed in the plugin while it is working ok when the snippet is fired from within a resource?
Quote from: omegerard at Dec 12, 2018, 06:50 AM
If image+ is used in a snippet (runsnippet), it works as expected
$image = $modx->runsnippet('imageplus', array(
'tvname' => 'tv',
'docid' => $resourceID
The same code used in a plugin (for an OnBeforeDocFormSave system event) turns saving a resource into a loop.
Can anyone explain this?
Do I have to specify the output in the plugin? How?