Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 11 |
|
0.00% |
0 / 3 |
CRAP | |
0.00% |
0 / 1 |
| CrudGroupsService | |
0.00% |
0 / 11 |
|
0.00% |
0 / 3 |
20 | |
0.00% |
0 / 1 |
| getClassService | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| delete | |
0.00% |
0 / 2 |
|
0.00% |
0 / 1 |
2 | |||
| createFromArray | |
0.00% |
0 / 8 |
|
0.00% |
0 / 1 |
6 | |||
| 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-2014 (original work) Open Assessment Technologies SA |
| 19 | */ |
| 20 | |
| 21 | namespace oat\taoGroups\models; |
| 22 | |
| 23 | use core_kernel_classes_Resource; |
| 24 | use oat\generis\model\OntologyRdf; |
| 25 | use oat\generis\model\OntologyRdfs; |
| 26 | use tao_models_classes_CrudService; |
| 27 | |
| 28 | /** |
| 29 | * Crud services implements basic CRUD services, orginally intended for |
| 30 | * REST controllers/ HTTP exception handlers. |
| 31 | * Consequently the signatures and behaviors is closer to REST and throwing HTTP like exceptions |
| 32 | * |
| 33 | * @author Patrick Plichart, patrick@taotesting.com |
| 34 | */ |
| 35 | class CrudGroupsService extends tao_models_classes_CrudService |
| 36 | { |
| 37 | /** |
| 38 | * (non-PHPdoc) |
| 39 | * |
| 40 | * @see tao_models_classes_CrudService::getClassService() |
| 41 | */ |
| 42 | protected function getClassService() |
| 43 | { |
| 44 | return GroupsService::singleton(); |
| 45 | } |
| 46 | |
| 47 | /** |
| 48 | * (non-PHPdoc) |
| 49 | * |
| 50 | * @see tao_models_classes_CrudService::delete() |
| 51 | * |
| 52 | * @param mixed $resource |
| 53 | */ |
| 54 | public function delete($resource) |
| 55 | { |
| 56 | $this->getClassService()->deleteGroup(new core_kernel_classes_Resource($resource)); |
| 57 | //parent::delete($resource) |
| 58 | return true; |
| 59 | } |
| 60 | |
| 61 | /** |
| 62 | * @author Patrick Plichart, patrick@taotesting.com |
| 63 | * |
| 64 | * @param array $propertiesValues |
| 65 | * |
| 66 | * @return core_kernel_classes_Resource |
| 67 | */ |
| 68 | public function createFromArray(array $propertiesValues) |
| 69 | { |
| 70 | if (!isset($propertiesValues[OntologyRdfs::RDFS_LABEL])) { |
| 71 | $propertiesValues[OntologyRdfs::RDFS_LABEL] = ''; |
| 72 | } |
| 73 | $type = $propertiesValues[OntologyRdf::RDF_TYPE] ?? $this->getRootClass(); |
| 74 | $label = $propertiesValues[OntologyRdfs::RDFS_LABEL]; |
| 75 | //hmmm |
| 76 | unset($propertiesValues[OntologyRdfs::RDFS_LABEL]); |
| 77 | unset($propertiesValues[OntologyRdf::RDF_TYPE]); |
| 78 | $resource = parent::create($label, $type, $propertiesValues); |
| 79 | |
| 80 | return $resource; |
| 81 | } |
| 82 | } |