/** * @param string $action * @param array $properties * * @return array */ public static function runProcessor($action = '', array $properties = array()) { $options = array(); $namespace = self::$modx->getOption('ns', $properties, null, true); if ($namespace) { $corePath = self::$modx->getOption("{$namespace}.core_path", null); if (!$corePath and $ns = self::$modx->getObject('modNamespace', $namespace)) { $corePath = $ns->getCorePath(); } self::$modx->addPackage($namespace, $corePath . "model/"); $options['processors_path'] = $corePath . 'processors/'; } if (!empty($properties['location'])) { $options['location'] = $properties['location']; } self::$modx->error->reset(); $response = self::$modx->runProcessor($action, $properties, $options); if ($response instanceof modProcessorResponse) { $output = array('success' => !$response->isError(), 'message' => $response->getMessage(), 'response' => self::$modx->fromJSON($response->getResponse()), 'errors' => $response->getFieldErrors()); } else { $output = array('success' => false, 'message' => $response, 'response' => array(), 'errors' => array()); } return $output; }