Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 6 |
|
0.00% |
0 / 2 |
CRAP | |
0.00% |
0 / 1 |
| ClassPropertyCacheWarmupListener | |
0.00% |
0 / 6 |
|
0.00% |
0 / 2 |
6 | |
0.00% |
0 / 1 |
| __construct | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| handleEvent | |
0.00% |
0 / 5 |
|
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) 2023 (original work) Open Assessment Technologies SA; |
| 19 | * |
| 20 | */ |
| 21 | |
| 22 | declare(strict_types=1); |
| 23 | |
| 24 | namespace oat\tao\model\listener; |
| 25 | |
| 26 | use oat\generis\Helper\PropertyCache; |
| 27 | use oat\generis\model\data\event\CacheWarmupEvent; |
| 28 | use oat\generis\model\data\Ontology; |
| 29 | use oat\oatbox\reporting\Report; |
| 30 | |
| 31 | class ClassPropertyCacheWarmupListener |
| 32 | { |
| 33 | public function __construct(Ontology $model) |
| 34 | { |
| 35 | $this->model = $model; |
| 36 | } |
| 37 | |
| 38 | public function handleEvent(CacheWarmupEvent $event): void |
| 39 | { |
| 40 | $class = new \core_kernel_classes_Class('http://www.w3.org/1999/02/22-rdf-syntax-ns#Property'); |
| 41 | $properties = $class->getInstances(true); |
| 42 | $properties = array_unique(array_keys($properties)); |
| 43 | |
| 44 | PropertyCache::warmupCachedValuesByProperties($properties); |
| 45 | |
| 46 | $event->addReport(Report::createInfo('Generated property cache.')); |
| 47 | } |
| 48 | } |