Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 10 |
|
0.00% |
0 / 3 |
CRAP | |
0.00% |
0 / 1 |
| LoadStylesheetService | |
0.00% |
0 / 10 |
|
0.00% |
0 / 3 |
12 | |
0.00% |
0 / 1 |
| load | |
0.00% |
0 / 8 |
|
0.00% |
0 / 1 |
2 | |||
| getFileManagement | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| getStylesheetRepository | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| 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) 2021 (original work) Open Assessment Technologies SA; |
| 19 | */ |
| 20 | |
| 21 | declare(strict_types=1); |
| 22 | |
| 23 | namespace oat\taoMediaManager\model\sharedStimulus\css\service; |
| 24 | |
| 25 | use Psr\Http\Message\StreamInterface; |
| 26 | use oat\oatbox\service\ConfigurableService; |
| 27 | use oat\taoMediaManager\model\fileManagement\FileManagement; |
| 28 | use oat\taoMediaManager\model\sharedStimulus\css\dto\LoadStylesheet; |
| 29 | use oat\taoMediaManager\model\sharedStimulus\css\repository\StylesheetRepository; |
| 30 | |
| 31 | class LoadStylesheetService extends ConfigurableService |
| 32 | { |
| 33 | public function load(LoadStylesheet $loadStylesheetDTO): StreamInterface |
| 34 | { |
| 35 | $path = $this->getStylesheetRepository()->getPath($loadStylesheetDTO->getUri()); |
| 36 | $stylesheet = $loadStylesheetDTO->getStylesheetUri(); |
| 37 | $link = $path |
| 38 | . DIRECTORY_SEPARATOR |
| 39 | . StylesheetRepository::STYLESHEETS_DIRECTORY |
| 40 | . DIRECTORY_SEPARATOR |
| 41 | . $stylesheet; |
| 42 | |
| 43 | return $this->getFileManagement()->getFileStream($link); |
| 44 | } |
| 45 | |
| 46 | private function getFileManagement(): FileManagement |
| 47 | { |
| 48 | return $this->getServiceLocator()->get(FileManagement::SERVICE_ID); |
| 49 | } |
| 50 | |
| 51 | private function getStylesheetRepository(): StylesheetRepository |
| 52 | { |
| 53 | return $this->getServiceLocator()->get(StylesheetRepository::class); |
| 54 | } |
| 55 | } |