Skip to content

Instantly share code, notes, and snippets.

@silentworks
Last active December 14, 2015 08:38
Show Gist options
  • Save silentworks/5058812 to your computer and use it in GitHub Desktop.
Save silentworks/5058812 to your computer and use it in GitHub Desktop.
This is how you could return your processor with specific system settings.
<?php
class MyGetListProcessor extends modObjectGetProcessor {
public $classKey = 'className';
public function process() {
$data = array();
$settings = array(
'emailsender' => $this->modx->getOption('emailsender')
);
$data['total'] = count($settings);
return $this->outputArray($settings, $data['total']);;
}
}
return 'MyGetListProcessor';
@gadgetto
Copy link

gadgetto commented Mar 2, 2013

Hi,

below is the working code (based on your sample)! The modObjectGetProcessor didn't work (at least I couldn't get it to work)

<?php
class GoodNewsGetSettingsProcessor extends modProcessor {

    public function process() {

        $settings = array(
            'resource_container'  => $this->modx->getOption('goodnews.resource_container'),
            'test_subject_prefix' => $this->modx->getOption('goodnews.test_subject_prefix'),
            // integer typecasting required to work with ExtJS.SliderField
            'mailing_bulk_size'   => (int)$this->modx->getOption('goodnews.mailing_bulk_size'),
            'admin_groups'        => $this->modx->getOption('goodnews.admin_groups'),
        );

        $response['success'] = true;
        $response['data'] = $settings;

        //$this->modx->log(modX::LOG_LEVEL_INFO, 'response: '.$this->modx->toJSON($response));

        return $this->modx->toJSON($response);
    }

}
return 'GoodNewsGetSettingsProcessor';

The class returns this Json string and all form field of the panel are filled with it's values:

{"success":true,"data":{"resource_container":"14","test_subject_prefix":"TEST - ","mailing_bulk_size":40,"admin_groups":"Administrator"}}

Thanks again for pushing me to the right direction!

@silentworks
Copy link
Author

Weird that modObjectGetProcessor didnt work since it extends modProcessor. Maybe it was missing a required variable. Good to see you got this working anyway and thanks for posting back your working example.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment