コード例 #1
0
 /**
  * @test
  */
 public function flushTheData()
 {
     $chunk = new XMLChunk();
     $chunk->page = 3;
     $chunk->section = 4;
     $chunk->xml = '<foot/>';
     $this->obj->save($chunk);
     $chunks = $this->obj->find();
     $this->assertInternalType('array', $chunks);
     $this->assertSame(1, count($chunks));
     $this->obj->flush();
     $chunks = $this->obj->find();
     $this->assertInternalType('array', $chunks);
     $this->assertSame(0, count($chunks));
 }
コード例 #2
0
ファイル: Chunker.php プロジェクト: bluem/teishredder
 /**
  * Method that's called when a chunk's end is encountered
  */
 protected function finishChunk()
 {
     // <pb> and <milestone> have been interpreted, now we can remove them
     $this->xml = preg_replace('#<(?:pb|milestone)\\b[^>]*>#', '', $this->xml);
     $plaintext = $this->plaintextConverter->convert($this->xml);
     if ($this->pageObj) {
         $this->pageObj->plaintext .= ' ' . trim($plaintext);
     }
     if (empty($this->chunks[$this->currentChunk])) {
         // This method might get called in cases where startChunk()
         // had not been called when it started.
         return;
     }
     $chunk = $this->chunks[$this->currentChunk];
     $chunk->xml = trim($this->xml);
     $chunk->plaintext = $plaintext;
     $chunk->poststack = join(' ', $this->poststack);
     $this->xmlChunkGateway->save($chunk);
     // Dispose of the chunk
     unset($this->chunks[$this->currentChunk]);
 }