public function initialize() { $data = $this->getProperty('data'); if (empty($data)) { return $this->modx->lexicon('invalid_data'); } $properties = $this->modx->fromJSON($data); $this->setProperties($properties); $this->unsetProperty('data'); return parent::initialize(); }
public function initialize() { $user = (int) $this->getProperty('fk', 0); if (!$user) { return $this->modx->lexicon('user_err_ns'); } $key = $this->getProperty('key', ''); if (empty($key)) { return $this->modx->lexicon($this->objectType . '_err_ns'); } $this->object = $this->modx->getObject($this->classKey, array('key' => $key, 'user' => $user)); if (!$this->object) { return $this->modx->lexicon($this->objectType . '_err_nf'); } if ($this->checkSavePermission && $this->object instanceof modAccessibleObject && !$this->object->checkPolicy('save')) { return $this->modx->lexicon('access_denied'); } return parent::initialize(); }