public static function construct(BusinessProcess $bp, Session $session) { $key = 'changes.' . $bp->getName(); $changes = new ProcessChanges(); $changes->sessionKey = $key; if ($actions = $session->get($key)) { foreach ($actions as $string) { $changes->push(NodeAction::unserialize($string)); } } $changes->session = $session; return $changes; }
/** * Return the base that should be used to calculate circle widths * * @param bool $create Whether to generate a new base if none is known yet * * @return float|null */ public function getCalculationBase($create) { if ($this->calculationBase === null) { $calculationBase = $this->session !== null ? $this->session->get('calculationBase') : null; if ($create) { $new = $this->generateCalculationBase(); if ($new > $calculationBase) { $this->calculationBase = $new; if ($this->session !== null) { $this->session->calculationBase = $new; } } else { $this->calculationBase = $calculationBase; } } else { return $calculationBase; } } return $this->calculationBase; }
/** * Clear all values and namespaces from the session cache */ public function clear() { parent::clear(); $this->namespaces = array(); $this->removedNamespaces = array(); }
/** * Read all values written to the underling session and make them accessible. */ public function read() { $this->clear(); $this->open(); foreach ($_SESSION as $key => $value) { if (strpos($key, self::NAMESPACE_PREFIX) === 0) { $namespace = new SessionNamespace($this); $namespace->setAll($value); $this->namespaces[substr($key, strlen(self::NAMESPACE_PREFIX))] = $namespace; } else { $this->set($key, $value); } } session_write_close(); $this->hasBeenTouched = true; }
public function testTrackingChangesWorks() { $ns = new SessionNamespace(); $this->assertFalse($ns->hasChanged(), 'A new empty session namespace seems to have changes'); $ns->test = 1; $this->assertTrue($ns->hasChanged(), 'A new session namespace with values seems not to have changes'); }