public function testStorage() { $storage = new Storage(new PHPStorageDriver($this->storageFile)); $data = array('eins' => 'dataeins', 'drei' => array('datadreiisarray'), 'vier' => 7); $storage->setData($data); $storage->persist(); $this->assertFileExists((string) $this->storageFile); unset($storage); /* Load Test */ $persistedStorage = new Storage(new PHPStorageDriver($this->storageFile)); $this->assertEquals($data, $persistedStorage->init()->getData()->toArray()); /* modify Test */ $persistedStorage->getData()->set('fuenf', 5); $data['fuenf'] = 5; $this->assertEquals($data, $persistedStorage->getData()->toArray()); $persistedStorage->persist(); /* load modified Test */ $modifiedStorage = new Storage(new PHPStorageDriver($this->storageFile)); $this->assertEquals(array(), $modifiedStorage->getData()->toArray()); $this->assertEquals($data, $modifiedStorage->init()->getData()->toArray()); }
public function onSourceFileChange(Event $event) { $file = $event->getData()->file; $storage = new Storage(new PHPStorageDriver(new File($this->getCache(), 'storage.changedFiles.php'))); $data = $storage->init()->getData(); $data->set(array('files', (string) $file), TRUE); $data->set(array('mtime'), time()); $storage->persist(); // wir haben die geänderte Datei noch gespeichert, jetzt compilen wir (denn das war gewünscht) if ($event->getData()->compile) { $out = new File(PSC::get(PSC::ROOT), 'psc-cms.phar.gz'); $libraryBuilder = new \Psc\Code\Build\LibraryBuilder($this, $logger = new \Psc\System\BufferLogger()); if ($libraryBuilder->isCompilingNeeded()) { $libraryBuilder->compile($out); $libraryBuilder->resetCompilingNeeded(); } } }