compiledTestConverter = $compiledTestConverter; } /** * @param tao_models_classes_service_StorageDirectory $directory * @return Generator In format $filePath => StreamInterface * @throws \common_Exception */ public function getFiles(tao_models_classes_service_StorageDirectory $directory) { $iterator = $directory->getFlyIterator(Directory::ITERATOR_FILE | Directory::ITERATOR_RECURSIVE); /* @var $file File */ foreach ($iterator as $file) { if ($this->isCompiledTestFile($file) && $this->compiledTestConverter !== null) { $file = $this->compiledTestConverter->convert($file, $directory); $fileStream = $file->readPsrStream(); $file->delete(); } else { $fileStream = $file->readPsrStream(); } yield $file->getPrefix() => $fileStream; } } /** * @param File $file * @return bool */ private function isCompiledTestFile(File $file) { return strpos($file->getBasename(), taoQtiTest_models_classes_QtiTestService::TEST_COMPILED_FILENAME) !== false; } }