Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 13 |
|
0.00% |
0 / 3 |
CRAP | |
0.00% |
0 / 1 |
| AssemblyExporter | |
0.00% |
0 / 13 |
|
0.00% |
0 / 3 |
42 | |
0.00% |
0 / 1 |
| getLabel | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| getExportForm | |
0.00% |
0 / 5 |
|
0.00% |
0 / 1 |
6 | |||
| export | |
0.00% |
0 / 7 |
|
0.00% |
0 / 1 |
12 | |||
| 1 | <?php |
| 2 | |
| 3 | /** |
| 4 | * This program is free software; you can redistribute it and/or |
| 5 | * modify it under the terms of the GNU General Public License |
| 6 | * as published by the Free Software Foundation; under version 2 |
| 7 | * of the License (non-upgradable). |
| 8 | * |
| 9 | * This program is distributed in the hope that it will be useful, |
| 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 | * GNU General Public License for more details. |
| 13 | * |
| 14 | * You should have received a copy of the GNU General Public License |
| 15 | * along with this program; if not, write to the Free Software |
| 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
| 17 | * |
| 18 | * Copyright (c) 2013 (original work) Open Assessment Technologies SA (under the project TAO-PRODUCT); |
| 19 | * |
| 20 | */ |
| 21 | |
| 22 | namespace oat\taoDeliveryRdf\model\export; |
| 23 | |
| 24 | use core_kernel_classes_Resource; |
| 25 | use core_kernel_classes_Class; |
| 26 | use oat\oatbox\service\ServiceManager; |
| 27 | use oat\taoDeliveryRdf\view\form\export\ExportForm; |
| 28 | |
| 29 | /** |
| 30 | * tao delivery assembly exporter |
| 31 | * |
| 32 | * @access public |
| 33 | * @author Joel Bout, <joel@taotesting.com> |
| 34 | * @package taoDelivery |
| 35 | |
| 36 | */ |
| 37 | class AssemblyExporter implements \tao_models_classes_export_ExportHandler |
| 38 | { |
| 39 | /** |
| 40 | * (non-PHPdoc) |
| 41 | * @see tao_models_classes_export_ExportHandler::getLabel() |
| 42 | */ |
| 43 | public function getLabel() |
| 44 | { |
| 45 | return __('Assembly'); |
| 46 | } |
| 47 | |
| 48 | /** |
| 49 | * (non-PHPdoc) |
| 50 | * @see tao_models_classes_export_ExportHandler::getExportForm() |
| 51 | */ |
| 52 | public function getExportForm(core_kernel_classes_Resource $resource) |
| 53 | { |
| 54 | if ($resource instanceof core_kernel_classes_Class) { |
| 55 | $formData = ['class' => $resource]; |
| 56 | } else { |
| 57 | $formData = ['instance' => $resource]; |
| 58 | } |
| 59 | $form = new ExportForm($formData); |
| 60 | return $form->getForm(); |
| 61 | } |
| 62 | |
| 63 | /** |
| 64 | * (non-PHPdoc) |
| 65 | * @see tao_models_classes_export_ExportHandler::export() |
| 66 | */ |
| 67 | public function export($formValues, $destination) |
| 68 | { |
| 69 | if (!isset($formValues['exportInstance']) || empty($formValues['exportInstance'])) { |
| 70 | throw new \common_Exception('No instance selected'); |
| 71 | } |
| 72 | |
| 73 | $delivery = new core_kernel_classes_Resource($formValues['exportInstance']); |
| 74 | $path = ServiceManager::getServiceManager() |
| 75 | ->get(AssemblyExporterService::class) |
| 76 | ->exportCompiledDelivery($delivery); |
| 77 | |
| 78 | return $path; |
| 79 | } |
| 80 | } |