本文整理汇总了PHP中modObjectUpdateProcessor::beforeSave方法的典型用法代码示例。如果您正苦于以下问题:PHP modObjectUpdateProcessor::beforeSave方法的具体用法?PHP modObjectUpdateProcessor::beforeSave怎么用?PHP modObjectUpdateProcessor::beforeSave使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类modObjectUpdateProcessor
的用法示例。
在下文中一共展示了modObjectUpdateProcessor::beforeSave方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: beforeSet
/**
* Override in your derivative class to do functionality before save() is run
* @return boolean
*/
public function beforeSet()
{
if ($this->merged) {
$smarttagTagresources = $this->merged->getMany('Tagresources');
if ($smarttagTagresources) {
$params = array();
foreach ($smarttagTagresources as $smarttagTagresource) {
$params[] = array('tag_id' => $this->object->get('id'), 'tmplvar_id' => $smarttagTagresource->get('tmplvar_id'), 'resource_id' => $smarttagTagresource->get('resource_id'));
}
$this->modx->removeCollection('smarttagTagresources', array('tag_id' => $this->merged->get('id')));
foreach ($params as $param) {
$smarttagTagresource = $this->modx->newObject('smarttagTagresources');
$smarttagTagresource->fromArray($param, '', true, true);
if ($smarttagTagresource->save() === false) {
$this->modx->log(modX::LOG_LEVEL_ERROR, __FILE__ . ' ');
$this->modx->log(modX::LOG_LEVEL_ERROR, __METHOD__ . ' ');
$this->modx->log(modX::LOG_LEVEL_ERROR, __LINE__ . ': Could not save new data ' . print_r($param, 1));
} else {
$this->updateTVResourceValue($smarttagTagresource);
}
}
}
}
$smarttagTagresources = $this->object->getMany('Tagresources');
if ($smarttagTagresources) {
foreach ($smarttagTagresources as $smarttagTagresource) {
$this->updateTVResourceValue($smarttagTagresource);
}
}
return parent::beforeSave();
}
示例2: beforeSave
public function beforeSave()
{
$hasLayout = (bool) $this->getProperty('haslayout');
$this->object->set('haslayout', $hasLayout);
$controller = $this->getProperty('controller');
if (empty($controller)) {
$this->addFieldError('controller', $this->modx->lexicon('controller_err_ns'));
}
/* verify parent */
$parent = $this->getProperty('parent', null);
if (!empty($parent)) {
$parent = $this->modx->getObject('modAction', $parent);
if (empty($parent)) {
$this->addFieldError('parent', $this->modx->lexicon('action_parent_err_nf'));
}
}
/* verify namespace */
$namespace = $this->getProperty('namespace');
if (empty($namespace)) {
$this->addFieldError('namespace', $this->modx->lexicon('namespace_err_nf'));
}
$namespace = $this->modx->getObject('modNamespace', $namespace);
if (empty($namespace)) {
$this->addFieldError('namespace', $this->modx->lexicon('namespace_err_nf'));
}
return parent::beforeSave();
}
示例3: beforeSave
public function beforeSave()
{
$name = $this->getProperty('tag');
$group = $this->getProperty('group');
$alias = $this->getProperty('alias');
if (empty($name) || empty($group)) {
if (empty($group)) {
$this->addFieldError('group', $this->modx->lexicon('tagger.err.group_name_ns'));
}
if (empty($name)) {
$this->addFieldError('tag', $this->modx->lexicon('tagger.err.tag_name_ns'));
}
} else {
if ($this->object->group != $group) {
$this->addFieldError('group', $this->modx->lexicon('tagger.err.tag_group_changed'));
}
if ($this->modx->getCount($this->classKey, array('tag' => $name, 'group' => $group, 'id:!=' => $this->object->id)) > 0) {
$this->addFieldError('tag', $this->modx->lexicon('tagger.err.tag_name_ae'));
}
}
if (!empty($alias)) {
$alias = $this->object->cleanAlias($alias);
if ($this->modx->getCount($this->classKey, array('alias' => $alias, 'group' => $group, 'id:!=' => $this->object->id)) > 0) {
$this->addFieldError('alias', $this->modx->lexicon('tagger.err.tag_alias_ae'));
} else {
$this->object->set('alias', $alias);
}
}
return parent::beforeSave();
}
示例4: beforeSave
public function beforeSave()
{
$label = $this->getProperty('label');
$type = $this->getProperty('type');
$default = $this->getProperty('default');
switch ($type) {
case 'select':
case 'checkbox':
case 'radio':
$values = $this->getProperty('values');
break;
default:
// textbox
$values = '';
$this->validationType = true;
}
$settings = array('label' => $label);
if (!empty($default)) {
$settings['default'] = $default;
}
if (!empty($values)) {
$settings['values'] = $values;
}
$this->object->set('settings', $this->modx->toJSON($settings));
return parent::beforeSave();
}
示例5: beforeSave
public function beforeSave()
{
/*print_r($this->object->toArray());
exit;*/
return parent::beforeSave();
}
示例6: beforeSave
public function beforeSave()
{
$policyId = $this->getProperty('policy');
$principalId = $this->getProperty('principal');
$target = $this->getProperty('target');
if ($principalId == null) {
$this->addFieldError('principal', $this->modx->lexicon('usergroup_err_ns'));
}
if (empty($policyId)) {
$this->addFieldError('policy', $this->modx->lexicon('access_policy_err_ns'));
}
/* validate for invalid data */
if (!empty($target)) {
/** @var modMediaSource $mediaSource */
$mediaSource = $this->modx->getObject('sources.modMediaSource', $target);
if (empty($mediaSource)) {
$this->addFieldError('target', $this->modx->lexicon('source_err_nf'));
}
if (!$mediaSource->checkPolicy('view')) {
$this->addFieldError('target', $this->modx->lexicon('access_denied'));
}
}
$policy = $this->modx->getObject('modAccessPolicy', $policyId);
if (empty($policy)) {
$this->addFieldError('policy', $this->modx->lexicon('access_policy_err_nf'));
}
$alreadyExists = $this->modx->getObject('modAccessCategory', array('principal' => $principalId, 'principal_class' => 'modUserGroup', 'target' => $target, 'policy' => $policyId, 'context_key' => $this->getProperty('context_key'), 'id:!=' => $this->object->get('id')));
if ($alreadyExists) {
$this->addFieldError('context_key', $this->modx->lexicon('access_source_err_ae'));
}
$this->object->set('principal_class', 'modUserGroup');
return parent::beforeSave();
}
示例7: beforeSave
public function beforeSave()
{
$active = $this->getProperty('active', null);
if ($active !== null) {
$this->object->set('active', (bool) $active);
}
return parent::beforeSave();
}
示例8: beforeSave
public function beforeSave()
{
if ($this->object->get('recipient') != $this->modx->user->get('id')) {
return $this->modx->lexicon($this->objectType . '_err_nfs');
}
$this->object->set('read', true);
return parent::beforeSave();
}
示例9: beforeSave
public function beforeSave()
{
$name = $this->getProperty('name');
if (empty($name)) {
$this->addFieldError('name', $this->modx->lexicon('role_err_ns_name'));
}
return parent::beforeSave();
}
示例10: beforeSave
public function beforeSave()
{
$this->setProfile();
$this->setRemoteData();
$this->validator = new modUserValidation($this, $this->object, $this->profile);
$this->validator->validate();
return parent::beforeSave();
}
示例11: beforeSave
/**
* @return bool
*/
public function beforeSave()
{
$text = $this->getProperty('text');
/** @var Tickets $Tickets */
if ($Tickets = $this->modx->getService('Tickets')) {
$this->object->fromArray(array('editedon' => time(), 'editedby' => $this->modx->user->id, 'text' => $Tickets->Jevix($text, 'Comment'), 'raw' => $text));
}
return parent::beforeSave();
}
示例12: beforeSave
public function beforeSave()
{
$this->object->set('constraint_class', 'modResource');
$actionId = $this->getProperty('action_id', null);
if ($actionId !== null) {
$this->object->set('action', $actionId);
}
return parent::beforeSave();
}
示例13: beforeSave
/** {inheritDoc} */
public function beforeSave()
{
/** @var modProcessorResponse $response */
$response = $this->modx->runProcessor('security/group/update', $this->getProperties());
if ($response->isError()) {
return $response->response;
}
return parent::beforeSave();
}
示例14: beforeSave
public function beforeSave()
{
if (!$this->verifyIdentity()) {
return "Неверный ключ или пароль был изменен ранее";
}
// else
$this->eraseCache();
$this->object->Profile->set('password', $this->getProperty('password'));
return parent::beforeSave();
}
示例15: beforeSave
public function beforeSave()
{
/* проверка на кружева */
if ($this->parent != $this->getProperty('parent', $this->object->get('parent'))) {
if (!$this->MlmSystem->Tools->checkClientParent($this->object, $this->getProperty('parent'))) {
$this->addFieldError('parent', $this->MlmSystem->lexicon('err_parent'));
}
}
return parent::beforeSave();
}