Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 18 |
|
0.00% |
0 / 1 |
CRAP | |
0.00% |
0 / 1 |
| ImportAssembly | |
0.00% |
0 / 18 |
|
0.00% |
0 / 1 |
12 | |
0.00% |
0 / 1 |
| __invoke | |
0.00% |
0 / 18 |
|
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) 2015-2018 (original work) Open Assessment Technologies SA (under the project TAO-PRODUCT); |
| 19 | * |
| 20 | */ |
| 21 | |
| 22 | namespace oat\taoDeliveryRdf\model\import; |
| 23 | |
| 24 | use oat\oatbox\extension\AbstractAction; |
| 25 | use oat\taoDeliveryRdf\model\DeliveryAssemblyService; |
| 26 | |
| 27 | /** |
| 28 | * Exports the specified Assembly |
| 29 | * |
| 30 | * @author Joel Bout |
| 31 | * |
| 32 | */ |
| 33 | class ImportAssembly extends AbstractAction |
| 34 | { |
| 35 | /** |
| 36 | * @param $params |
| 37 | * @return \common_report_Report |
| 38 | * @throws \common_Exception |
| 39 | * @throws \common_exception_Error |
| 40 | * @throws \common_ext_ExtensionException |
| 41 | */ |
| 42 | public function __invoke($params) |
| 43 | { |
| 44 | if (count($params) < 1) { |
| 45 | return new \common_report_Report( |
| 46 | \common_report_Report::TYPE_ERROR, |
| 47 | __('Usage: %s ASSEMBLY_FILE [ASSEMBLY_FILE_2] [ASSEMBLY_FILE_3] ...', __CLASS__) |
| 48 | ); |
| 49 | } |
| 50 | |
| 51 | \common_ext_ExtensionsManager::singleton()->getExtensionById('taoDeliveryRdf'); |
| 52 | |
| 53 | $deliveryClass = DeliveryAssemblyService::singleton() |
| 54 | ->getRootClass() |
| 55 | ->createSubClass('Import ' . \tao_helpers_Date::displayeDate(time())); |
| 56 | /** @var AssemblyImporterService $importer */ |
| 57 | $importer = $this->getServiceLocator()->get(AssemblyImporterService::class); |
| 58 | $report = new \common_report_Report( |
| 59 | \common_report_Report::TYPE_INFO, |
| 60 | __('Importing %1$s files into \'%2$s\'', count($params), $deliveryClass->getLabel()) |
| 61 | ); |
| 62 | |
| 63 | while (!empty($params)) { |
| 64 | $file = array_shift($params); |
| 65 | $report->add($importer->importDelivery($deliveryClass, $file)); |
| 66 | } |
| 67 | return $report; |
| 68 | } |
| 69 | } |