/** {@inheritDoc} */ public function beforeSet() { $fieldName = $this->getProperty('field_name', null); $fieldValue = $this->getProperty('field_value', null); $this->properties = array(); if (!is_null($fieldName) && !is_null($fieldValue)) { $this->setProperty($fieldName, $fieldValue); } return parent::beforeSet(); }
/** {@inheritDoc} */ 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'); return parent::initialize(); }
/** {@inheritDoc} */ public function beforeSet() { if (!($beforeSet = parent::beforeSet())) { return $beforeSet; } $sum = $this->getProperty('change_balance_sum', 0); if (empty($sum)) { return $this->MlmSystem->lexicon('err_sum'); } $type = $this->getProperty('change_balance_type', 0); if (empty($type)) { return $this->MlmSystem->lexicon('err_type'); } switch ($type) { case '1': $this->object->takeSum($sum); break; case '2': $this->object->putSum($sum); break; default: return $this->MlmSystem->lexicon('err_correct_type'); break; } $this->properties = array(); $valid = $this->object->validate(); if (!$valid) { $validator = $this->object->getValidator(); if ($validator->hasMessages()) { foreach ($validator->getMessages() as $message) { if ($message['field'] == 'balance') { $this->addFieldError('change_balance_sum', $message['message']); } else { $this->addFieldError($message['field'], $this->modx->lexicon($message['message'])); } } } } return true; }