object в зависимости от ситуации будет или modPropertySet или modTemplate|modSnippet и т.п. */ if(!$id = (int)$this->getProperty($this->primaryKeyField)){ if(!$elementType = $this->getProperty('elementType')){ return "Не был указан класс элемента"; } // else $this->classKey = $elementType; $id = (int)$this->getProperty('elementId'); switch($this->classKey){ } /* Здесь надо бы еще подключить соответствующие словари элементов */ } $this->setProperty($this->primaryKeyField, $id); return parent::initialize(); } /** * Return data as array * @return mixed */ public function getData() { return $this->modx->fromJSON($this->getProperty('data')); } public function beforeSet() { /* Необходимо установить эти значения, так как родительский процессор их перетирает, если не были переданы в параметры */ $this->setDefaultProperties(array( "name" => $this->object->get('name'), "category" => $this->object->get('category'), )); return parent::beforeSet(); } /** * Convert JSON data to array and unset default properties * @return bool */ public function beforeSave() { $this->object->setProperties($this->getData()); return parent::beforeSave();; } /** * Log the property set update from element manager action * @return void */ public function logManagerAction() { $key = $this->object ? $this->object->get($this->primaryKeyField) : $this->getProperty('elementType') . ' ' . $this->getProperty('elementId') . ' Default'; $this->modx->logManagerAction($this->objectType.'_update_from_element', $this->classKey, $key); } public function cleanup(){ return $this->success(''); } } return 'modPropertySetUpdateFromElementProcessor';