本文整理汇总了PHP中Opus_Document::addFile方法的典型用法代码示例。如果您正苦于以下问题:PHP Opus_Document::addFile方法的具体用法?PHP Opus_Document::addFile怎么用?PHP Opus_Document::addFile使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Opus_Document
的用法示例。
在下文中一共展示了Opus_Document::addFile方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: addFilesToDocument
/**
*
* @param string $docId
* @param array $files
* @throws Application_Exception in case database contains no document with id $docID
*/
public function addFilesToDocument($docId, $files)
{
if (empty($files)) {
throw new Application_Exception('no files for import');
}
$document = null;
try {
$document = new Opus_Document($docId);
} catch (Opus_Model_NotFoundException $e) {
throw new Application_Exception('no document found for id ' . $docId, null, $e);
}
$log = $this->getLogger();
$validFilenames = $this->getNamesOfIncomingFiles();
foreach ($files as $file) {
$log->debug('check filename ' . $file);
if (in_array($file, $validFilenames)) {
$pathname = $this->__importFolder . DIRECTORY_SEPARATOR . $file;
$log->info('import file ' . $pathname);
$docfile = $document->addFile();
$docfile->setTempFile($pathname);
$docfile->setPathName($file);
$docfile->setLabel($file);
try {
$document->store();
$log->info('import of file ' . $pathname . ' successful');
} catch (Exception $e) {
$log->err('import of file ' . $pathname . ' failed: ' . $e->getMessage());
}
$log->info('try to delete file ' . $pathname);
if (!unlink($pathname)) {
$log->err('could not delete file ' . $pathname);
}
}
}
}
示例2: testClearDocumentWithFile
public function testClearDocumentWithFile()
{
$this->markTestIncomplete('TODO: Re-enable, as soon as OPUSVIER-1220 is fixed.');
$path = '/tmp/opus4-test/' . uniqid() . "/src";
mkdir($path, 0777, true);
$filepath = $path . DIRECTORY_SEPARATOR . "foobar.pdf";
touch($filepath);
$document = new Opus_Document($this->documentId);
$document->addFile()->setTempFile($filepath)->setPathName('foobar.pdf')->setLabel('Volltextdokument (PDF)');
$document->store();
$helper = new Review_Model_ClearDocumentsHelper();
$helper->clear(array($this->documentId), 23, $this->person);
$document = new Opus_Document($this->documentId);
$this->assertEquals('published', $document->getServerState());
$this->assertEquals(1, count($document->getPersonReferee()));
$enrichments = $document->getEnrichment();
$this->assertEquals(1, count($enrichments));
$this->assertEquals(23, $enrichments[0]->getValue());
}