Unable to load processor for action

Does the action ‘mgr/default/stickytoggle’ look correct here, please, or is my naming/path convention incorrect?

            MODx.Ajax.request({
                url: MODx.config.connector_url,
                params: {
                    action: 'mgr/default/stickytoggle',
                    id: rec.get('id'),
                    sticky: rec.get('sticky') ? 0 : 1
                },
                listeners: {
                    success: function(r) {
                        if (r.success) {
                            rec.set('sticky', r.object.sticky);
                            grid.getView().refresh();
                            MODx.msg.status({
                                title: 'Success',
                                message: 'Sticky toggled!',
                                delay: 2
                            });
                        }
                    },
                    failure: function(r) {
                        MODx.msg.alert('Error', r.message || 'Could not toggle sticky');
                    }
                }
            });

As per Harry’s video I have also tried mgr\default\stickytoggle, Pascal case and various other combinations. Just can’t crack the formula which - is this correct? - I think has changed since an ExtJS upgrade, throwing off pretty much all the relevant MODX documentation?

Here is the error…

(ERROR @ core/src/Revolution/modX.php : 1794) Unable to load processor for action “mgr/default/stickytoggle”, it does not exist as an autoloadable class that extends \MODX\Revolution\Processors\Processor, and also not as a file in “core/src/Revolution/Processors/mgr/migx/stickytoggle.class.php”

I am using MODX 3.1.1-pl with MIGX 3.0.5-beta, trying to setup a processor for a MIGX form function. My Processor Path is defined as core/components/mycomponent/processors/.

What video exactly?

No, the Ext.js version hasn’t changed in years.
But in MODX 3, processors work a bit differently and most of the code examples are still for MODX 2.

There is also a difference, if you use the MIGX connector, or if you use the default MODX connector (MODx.config.connector_url).


In this case as you are using MODX 3 (and likely have your own namespace and a bootstrap.php file), try putting the processor in a ...core/components/mycomponent/src/Processors/ folder, and then use the fully qualified class name as the action.

For example like this:

for a processor like this

Thank you Harry, clearly I am cocking something up. Again.

Yes, I was following the SimpleExtra Processor video: https://www.youtube.com/watch?v=vuzkrDZJ-3M

When I use this syntax…

action: 'Dccontent\\Processors\\Sample'

…I get this error and the backslashes are stripped…

core/src/Revolution/modX.php : 1794) Unable to load processor for action “DccontentProcessorsSample”, it does not exist as an autoloadable class that extends \MODX\Revolution\Processors\Processor, and also not as a file in “core/src/Revolution/Processors/DccontentProcessorsSample.class.php”

I try this and get the same error with the forward slashes retained…

action: 'Dccontent/Processors/Sample'

core/src/Revolution/modX.php : 1794) Unable to load processor for action “Dccontent/Processors/Sample”, it does not exist as an autoloadable class that extends \MODX\Revolution\Processors\Processor, and also not as a file in “core/src/Revolution/Processors/Dccontent/Processors/Sample.class.php”

Just to try to have a processor load I am pointing to an abridged Sample.php located in dccontent/src/Processors

namespace Dccontent\Processors;

use MODX\Revolution\Processors\Processor;

class Sample extends Processor{

}

This is my component’s bootstrap…


/**
 * @var \MODX\Revolution\modX $modx
 * @var array $namespace
 */

use Dccontent\Dccontent;
use xPDO\xPDO;

// Add the service
try {
    // Add the package and model classes
    $modx->addPackage('Dccontent\\Model\\', $namespace['path'] . 'src/', null, 'Dccontent\\');

    if (class_exists('Dccontent\\Dccontent')) {
        $modx->services->add('Dccontent', function($c) use ($modx) {
            return new Dccontent($modx);
        });
    }
}
catch (\Exception $e) {
    $modx->log(xPDO::LOG_LEVEL_ERROR, $e->getMessage());
}

So where is your JS code (MODx.Ajax.request({ ...) located? In a separate *.js file?

If the JS code is a string inside PHP, then try using four backslashes
'Dccontent\\\\Processors\\\\Sample'
so that the backslashes are escaped twice.

1 Like

That was it. I needed \\\\, not just \\.

My word, I lost some hair over that.

Thank you Harry. Now I shall write my processor, wish me luck!

This topic was automatically closed 2 days after discussion ended and a solution was marked. New replies are no longer allowed. You can open a new topic by clicking the link icon below the original post or solution and selecting “+ New Topic”.

I recently saw a similar case where, in MODX 3, it helped to tack mgr/ onto the end of the URL and use the rest as the action. It’s not exactly your situation, because I was using $modx->runProcessor(), but it might help someone in a similar situation.