Beispiel #1
0
 /**
  * Construct state.
  *
  * @param Store $store
  *            Store to load/save data from/to.
  * @param bool $mutable
  *            Whether state is mutable (true) or read-only (false).
  * @throws AccessException If state could not be read.
  */
 public function __construct(Store $store, $mutable = true)
 {
     parent::__construct();
     $this->store = $store;
     try {
         $this->store->open($mutable);
         $this->data = $this->store->read();
     } catch (AccessException $e) {
         throw new AccessException('Could not read state: ' . $e->getMessage(), null, $e);
     }
 }
Beispiel #2
0
 /**
  * Save configuration. If this is not the root configuration, the root
  * configuration will be saved instead.
  * @return boolean True if the configuration was saved.
  */
 public function save()
 {
     if ($this->root !== $this) {
         return $this->root->save();
     }
     if (!isset($this->store)) {
         return false;
     }
     if (!$this->updated) {
         return true;
     }
     $this->store->open(true);
     $this->store->write($this->data);
     $this->store->close();
     $this->updated = false;
     return true;
 }
Beispiel #3
0
 /**
  * Reopen a closed session.
  * @return boolean True on success, false on failure.
  */
 public function open()
 {
     $this->store->open(true);
 }