/** * * @author Patrick Plichart, <*****@*****.**> * @param array $propertiesValues * @return core_kernel_classes_Resource */ public function createFromArray(array $propertiesValues) { if (!isset($propertiesValues[RDFS_LABEL])) { $propertiesValues[RDFS_LABEL] = ""; } $type = isset($propertiesValues[RDF_TYPE]) ? $propertiesValues[RDF_TYPE] : $this->getRootClass(); $label = $propertiesValues[RDFS_LABEL]; // hmmm unset($propertiesValues[RDFS_LABEL]); unset($propertiesValues[RDF_TYPE]); $resource = parent::create($label, $type, $propertiesValues); return $resource; }
/** * @param array parameters an array of property uri and values */ public function createFromArray(array $propertiesValues) { if (!isset($propertiesValues[RDFS_LABEL])) { $propertiesValues[RDFS_LABEL] = ""; } $type = isset($propertiesValues[RDF_TYPE]) ? $propertiesValues[RDF_TYPE] : $this->getRootClass(); $label = $propertiesValues[RDFS_LABEL]; unset($propertiesValues[RDFS_LABEL]); unset($propertiesValues[RDF_TYPE]); $itemContent = null; if (isset($propertiesValues[taoItems_models_classes_ItemsService::PROPERTY_ITEM_CONTENT])) { $itemContent = $propertiesValues[taoItems_models_classes_ItemsService::PROPERTY_ITEM_CONTENT]; unset($propertiesValues[taoItems_models_classes_ItemsService::PROPERTY_ITEM_CONTENT]); } $resource = parent::create($label, $type, $propertiesValues); if (isset($itemContent)) { $this->itemsServices->setItemContent($resource, $itemContent); } return $resource; }
/** * * @author Patrick Plichart, patrick@taotesting.com * @param array $propertiesValues * @throws \common_exception_MissingParameter * @throws \common_exception_PreConditionFailure * @return \core_kernel_classes_Resource */ public function createFromArray($propertiesValues = array()) { // mandatory parameters if (!isset($propertiesValues[PROPERTY_USER_LOGIN])) { throw new \common_exception_MissingParameter("login"); } if (!isset($propertiesValues[PROPERTY_USER_PASSWORD])) { throw new \common_exception_MissingParameter("password"); } // default values if (!isset($propertiesValues[PROPERTY_USER_UILG])) { $propertiesValues[PROPERTY_USER_UILG] = \tao_helpers_I18n::getLangResourceByCode(DEFAULT_LANG); } if (!isset($propertiesValues[PROPERTY_USER_DEFLG])) { $propertiesValues[PROPERTY_USER_DEFLG] = \tao_helpers_I18n::getLangResourceByCode(DEFAULT_LANG); } if (!isset($propertiesValues[RDFS_LABEL])) { $propertiesValues[RDFS_LABEL] = ""; } // check if login already exists $userService = \tao_models_classes_UserService::singleton(); if ($userService->loginExists($propertiesValues[PROPERTY_USER_LOGIN])) { throw new \common_exception_PreConditionFailure("login already exists"); } $propertiesValues[PROPERTY_USER_PASSWORD] = \core_kernel_users_Service::getPasswordHash()->encrypt($propertiesValues[PROPERTY_USER_PASSWORD]); $type = isset($propertiesValues[RDF_TYPE]) ? $propertiesValues[RDF_TYPE] : $this->getRootClass(); $label = $propertiesValues[RDFS_LABEL]; // hmmm unset($propertiesValues[RDFS_LABEL]); unset($propertiesValues[RDF_TYPE]); $resource = parent::create($label, $type, $propertiesValues); $this->getClassService()->setTestTakerRole($resource); return $resource; }