So... having some great times with the new class-based processors. Setting up CMPs that pull from external API data sources, so as such I don't have a DB model to use.
I can really see the power available with the processors, but when trying to use them for non-db data it just seems a bit hacky, and I wanted to get some opinions on best practice.
so.. here's my custom processor...
<?php
class McmCampaignRemoveProcessor extends modObjectRemoveProcessor {
public $languageTopics = array('mcm:default');
public $classKey = 'McmCampaign';
public $objectType = 'mcm.campaign';
//-----------------------------------------------------------------------------------------------------------
//-----------------------------------------------------------------------------------------------------------
public function initialize(){
global $modx;
$modx->addPackage('delete',$modx->getOption('core_path').'components/mcm/'.'processors/campaigns/','');
require_once $modx->getOption('core_path').'components/mcm/lib/mcm/ModxCampaignMonitor.class.php';
$this->MCM = new ModxCampaignMonitor();
return parent::initialize();
}//
//-----------------------------------------------------------------------------------------------------------
//-----------------------------------------------------------------------------------------------------------
public function process(){
global $modx;
$props = $this->getProperties();
/* if($result != "SUCCESS"){
return $this->failure('ERROR '.print_r($result,true).' - Unknown');
};
*/
return $this->failure('Campaign has been deleted');
}//
}
return 'McmCampaignRemoveProcessor';
Now I have followed this outline for create & getList processors without a problem, but as soon as I try with a remove processor it kept kicking up _err_ns errors. I eventually got around the issue by changing the initialize() function to return true rather than the parent value but this approach just seems a bit hacky, maybe its just me.
Should I be extending a higher-level class to get a non-db processor?