/** * Make sure we clean up names */ public function set($k, $v = null, $vType = '') { if ($k == 'name') { $v = strip_tags(trim(preg_replace('/\\s+/', ' ', $v))); } return parent::set($k, $v, $vType); }
/** * Set a field value by the field key or name. * * {@inheritdoc} * * Additional logic added for the following fields: * -alias: Applies {@link modResource::cleanAlias()} * -contentType: Calls {@link modResource::addOne()} to sync contentType * -content_type: Sets the contentType field appropriately */ public function set($k, $v = null, $vType = '') { switch ($k) { case 'alias': $v = $this->cleanAlias($v); break; } return parent::set($k, $v, $vType); }
function set($k, $v = null, $vType = '') { switch ($k) { // Protect changing class_key case 'class_key': $v = $this->get($k); break; } return parent::set($k, $v, $vType); }
/** * Override set to trim string fields * * {@inheritDoc} */ public function set($k, $v = null, $vType = '') { switch ($k) { case 'name': case 'description': if (is_string($v)) { $v = trim($v); } break; } return parent::set($k, $v, $vType); }
/** * Overrides xPDOObject::set to provide custom functionality and automation * for the closure tables that persist the board map. * * @param string $k * @param mixed $v * @param string $vType * @return boolean */ public function set($k, $v = null, $vType = '') { $oldParentId = $this->get('parent'); $oldCategory = $this->get('category'); $set = parent::set($k, $v, $vType); if ($set && $k == 'parent' && $v != $oldParentId && !$this->isNew()) { $this->parentChanged = true; } else { if ($set && $k == 'category' && $v != $oldCategory && !$this->isNew()) { $this->categoryChanged = true; $this->xpdo->log(modX::LOG_LEVEL_ERROR, print_r($this->get('category'), true)); } } return $set; }