/** {inheritDoc} */ public function initialize() { $primaryKey = $this->getProperty($this->primaryKeyField, false); if (empty($primaryKey)) { return $this->modx->lexicon($this->classKey . '_err_ns'); } if (!$this->modx->getCount($this->classKey, array('id' => $primaryKey, 'class_key' => $this->classKey)) && ($res = $this->modx->getObject('modResource', $primaryKey))) { $res->set('class_key', $this->classKey); $res->save(); } return parent::initialize(); }
public function initialize() { if (!($id = (int) $this->getProperty('resource_id'))) { return "Не указан ID документа"; } // else $this->setProperty('id', $id); if (!($src = $this->getProperty('src'))) { return "Не указана картинка"; } // else $this->setProperty('image', $src); return parent::initialize(); }
public function initialize() { $data = $this->getProperty('data'); if (empty($data)) { return $this->modx->lexicon('invalid_data'); } $data = $this->modx->fromJSON($data); if (empty($data)) { return $this->modx->lexicon('invalid_data'); } $this->setProperties($data); $this->unsetProperty('data'); $this->setProperty('clearCache', true); return parent::initialize(); }