/** * @return void */ private function initCollections() { $this->source = new SourceCollection($this->srcDir); $srcFile = $this->xmlDir . '/source.xml'; if (file_exists($srcFile)) { $dom = new fDOMDocument(); $dom->load($srcFile); $this->source->import($dom); } $this->index = new IndexCollection(); $srcFile = $this->xmlDir . '/index.xml'; if (file_exists($srcFile)) { $dom = new fDOMDocument(); $dom->load($srcFile); $this->index->import($dom); } }
private function saveSources() { foreach ($this->files as $file) { $tokenDom = $file->getTokens(); $tokenDom->formatOutput = TRUE; $tokenDom->preserveWhiteSpace = FALSE; $relName = 'tokens/' . $file->getRelative($this->srcDir, FALSE) . '.xml'; $fname = $this->xmlDir . '/' . $relName; $dir = dirname($fname); if (!file_exists($dir)) { mkdir($dir, 0777, true); } try { $tokenDom->save($fname); } catch (fDOMException $e) { throw new ProjectException(sprintf("Internal Error: Token xml file '%s' could not be saved.", $fname), ProjectException::UnitCouldNotBeSaved, $e); } $this->source->setTokenFileReference($file, $relName); } $sourceDom = $this->source->export(); $sourceDom->formatOutput = TRUE; $sourceDom->preserveWhiteSpace = FALSE; $sourceDom->save($this->xmlDir . '/source.xml'); }