/** * Decode a compressed inventory file */ public function decodeInventoryAction() { $input = $this->getRequest()->getParam('input_file'); if (!is_file($input) or !is_readable($input)) { $model = new \Zend\Mvc\Console\View\ViewModel(); $model->setErrorLevel(10); $model->setResult("Input file does not exist or is not readable.\n"); return $model; } try { return $this->_inventoryDecode->filter(\Library\FileObject::fileGetContents($input)); } catch (\InvalidArgumentException $e) { $model = new \Zend\Mvc\Console\View\ViewModel(); $model->setErrorLevel(11); $model->setResult($e->getMessage() . "\n"); return $model; } }
/** * Upload a file * * @param string $fileName File name * @return \Zend\Http\Response Server response */ public function uploadFile($fileName) { return $this->uploadData(\Library\FileObject::fileGetContents($fileName)); }
public function testFileGetContentsError() { $this->setExpectedException('RuntimeException', 'Error reading from file vfs://root/test.txt'); // Force error by requesting nonexistent file FileObject::fileGetContents('vfs://root/test.txt'); }