Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 12 |
|
0.00% |
0 / 2 |
CRAP | |
0.00% |
0 / 1 |
| taoItems_models_classes_search_ItemContentTokenizer | |
0.00% |
0 / 12 |
|
0.00% |
0 / 2 |
42 | |
0.00% |
0 / 1 |
| getStrings | |
0.00% |
0 / 4 |
|
0.00% |
0 / 1 |
6 | |||
| getItemContentTokenizer | |
0.00% |
0 / 8 |
|
0.00% |
0 / 1 |
20 | |||
| 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) 2016 (original work) Open Assessment Technologies SA (under the project TAO-PRODUCT); |
| 19 | * |
| 20 | */ |
| 21 | |
| 22 | use oat\tao\model\search\tokenizer\ResourceTokenizer; |
| 23 | use oat\taoItems\model\search\IndexableItemModel; |
| 24 | |
| 25 | /** |
| 26 | * Item content tokenizer. |
| 27 | * |
| 28 | * @author Joel Bout <joel@taotesting.com> |
| 29 | * @author Jérôme Bogaerts <jerome@taotesting.com> |
| 30 | * @author Camille Moyon <camille@taotesting.com> |
| 31 | */ |
| 32 | class taoItems_models_classes_search_ItemContentTokenizer implements ResourceTokenizer |
| 33 | { |
| 34 | use \oat\generis\model\OntologyAwareTrait; |
| 35 | |
| 36 | /** |
| 37 | * Find item model tokenizer and send request to it to extract tokens |
| 38 | * |
| 39 | * @param core_kernel_classes_Resource $resource |
| 40 | * @return array |
| 41 | */ |
| 42 | public function getStrings(\core_kernel_classes_Resource $resource) |
| 43 | { |
| 44 | $tokenizer = $this->getItemContentTokenizer($resource); |
| 45 | if (is_null($tokenizer)) { |
| 46 | return []; |
| 47 | } |
| 48 | return $tokenizer->getStrings($resource); |
| 49 | } |
| 50 | |
| 51 | /** |
| 52 | * Get item content tokenizer associated to $resource e.q. item model |
| 53 | * If not return null |
| 54 | * |
| 55 | * @param core_kernel_classes_Resource $resource |
| 56 | * @return null|taoItems_models_classes_itemModel |
| 57 | */ |
| 58 | protected function getItemContentTokenizer(core_kernel_classes_Resource $resource) |
| 59 | { |
| 60 | $itemService = taoItems_models_classes_ItemsService::singleton(); |
| 61 | $model = $itemService->getItemModel($resource); |
| 62 | if (! is_null($model)) { |
| 63 | $impl = $itemService->getItemModelImplementation($model); |
| 64 | if (! is_null($impl)) { |
| 65 | if ($impl instanceof IndexableItemModel) { |
| 66 | return $impl->getItemContentTokenizer(); |
| 67 | } |
| 68 | } |
| 69 | } |
| 70 | return null; |
| 71 | } |
| 72 | } |