public function get($key) { if ($this->hasProperty($key)) { return parent::get($key); } if (array_key_exists($key, $this->settings)) { return $this->settings[$key]; } return parent::get($key); }
public function __unset($key) { if ($this->hasProperty($key)) { return parent::__set($key, $value); } if (array_key_exists($key, $this->settings)) { unset($this->settings[$key]); $this->hasBeenModified = true; } return $this; }
public function set($key, $value) { if ($key === 'groups') { $this->groups()->set($value); return $this; } elseif ($key === 'imports') { $this->imports()->set($value); return $this; } elseif ($key === 'arguments') { if (is_object($value)) { foreach ($value as $arg => $val) { $this->arguments()->set($arg, $val); } } return $this; } elseif ($key === 'vars') { $value = (array) $value; $unset = array(); foreach ($this->vars() as $k => $f) { if (!array_key_exists($k, $value)) { $unset[] = $k; } } foreach ($unset as $k) { unset($this->vars()->{$k}); } foreach ($value as $k => $v) { $this->vars()->set($k, $v); } return $this; } if ($this->propertyIsBoolean($key) && $value !== null) { if ($value === 'y' || $value === '1' || $value === true || $value === 1) { return parent::set($key, 'y'); } elseif ($value === 'n' || $value === '0' || $value === false || $value === 0) { return parent::set($key, 'n'); } elseif ($value === '') { return parent::set($key, null); } else { throw new ProgrammingError('Got invalid boolean: %s', var_export($value, 1)); } } if ($this->hasRelation($key)) { if (!$value) { return parent::set($key . '_id', null); } $class = $this->getRelationClass($key); $object = $class::load($value, $this->connection); if (in_array($object->object_type, array('object', 'external_object'))) { return parent::set($key . '_id', $object->id); } // TODO: what shall we do if it is a template? Fail? } return parent::set($key, $value); }
public function __destruct() { unset($this->resolveCache); unset($this->vars); unset($this->groups); unset($this->imports); unset($this->ranges); unset($this->arguments); parent::__destruct(); }
public static function logRemoval(DbObject $object, Db $db) { $data = array('object_name' => $object->object_name, 'action_name' => 'delete', 'author' => self::username(), 'object_type' => $object->getTableName(), 'old_properties' => json_encode($object->getOriginalProperties()), 'change_time' => date('Y-m-d H:i:s'), 'parent_checksum' => $db->getLastActivityChecksum()); $data['checksum'] = sha1(json_encode($data), true); $data['parent_checksum'] = Util::hex2binary($data['parent_checksum']); return self::create($data)->store($db); }