addUserClass("EmployeeDocument"); } * */ public abstract function initializeUserClasses(); /** * Override this method in module manager class to define file field mappings. If you have a table field that stores a name of a file which need to be * deleted from the disk when the record is deleted a file field mapping should be added. * @method initializeFieldMappings * @example public function initializeFieldMappings(){ $this->addFileFieldMapping('EmployeeDocument', 'attachment', 'name'); } */ public abstract function initializeFieldMappings(); /** * Override this method in module manager class to define DB error mappings. Some actions to your model classes trigger database errors. * These errors need to be translated to user friendly texts using DB error mappings * @method initializeDatabaseErrorMappings * @example public function initializeDatabaseErrorMappings(){ $this->addDatabaseErrorMapping('CONSTRAINT `Fk_User_Employee` FOREIGN KEY',"Can not delete Employee, please delete the User for this employee first."); $this->addDatabaseErrorMapping("Duplicate entry|for key 'employee'","A duplicate entry found"); } */ public abstract function initializeDatabaseErrorMappings(); /** * Override this method in module manager class to add model classes to this module. All the model classes defind for the module should be added here * @method setupModuleClassDefinitions * @example public function setupModuleClassDefinitions(){ $this->addModelClass('Employee'); $this->addModelClass('EmploymentStatus'); } */ public abstract function setupModuleClassDefinitions(); public function initQuickAccessMenu(){ } public function setModuleObject($obj){ $this->moduleObject = $obj; } public function getModuleObject(){ return $this->moduleObject; } public function setModuleType($type){ $this->moduleType = $type; } public function getModuleType(){ return $this->moduleType; } public function getModulePath(){ $subClass = get_called_class(); $reflector = new ReflectionClass($subClass); $fn = $reflector->getFileName(); $this->modulePath = realpath(dirname($fn)."/.."); LogManager::getInstance()->info("Module Path: [$subClass | $fn]".$this->modulePath); } public function getDashboardItemData(){ return array(); } public function getDashboardItem(){ $this->getModulePath(); if(!file_exists($this->modulePath."/dashboard.html")){ //LogManager::getInstance()->error("Dashboard file not found :".$this->modulePath."/dashboard.html"); return null; } $dashboardItem = file_get_contents($this->modulePath."/dashboard.html"); if(empty($dashboardItem)){ //LogManager::getInstance()->error("Dashboard file is empty :".$this->modulePath."/dashboard.html"); return null; } $data = $this->getDashboardItemData(); $data['moduleLink'] = $this->getModuleLink(); LogManager::getInstance()->info("Module Link:".$data['moduleLink']); foreach($data as $k => $v){ $dashboardItem = str_replace("#_".$k."_#", $v, $dashboardItem); } return $dashboardItem; } public function getDashboardItemIndex(){ $metaData = json_decode(file_get_contents($this->modulePath."/meta.json"),true); if(!isset($metaData['dashboardPosition'])){ return 100; }else{ return $metaData['dashboardPosition']; } } private function getModuleLink(){ $metaData = json_decode(file_get_contents($this->modulePath."/meta.json"),true); $mod = basename($this->modulePath); $group = basename(realpath($this->modulePath."/..")); //?g=admin&n=candidates&m=admin_Recruitment return CLIENT_BASE_URL."?g=".$group."&n=".$mod."&m=".$group."_".str_replace(" ","_",$metaData['label']); } public function setupRestEndPoints(){ } public function setupFileFieldMappings(&$fileFields){ foreach ($this->fileFieldMappings as $mapping){ if(empty($fileFields[$mapping[0]])){ $fileFields[$mapping[0]] = array(); } $fileFields[$mapping[0]][$mapping[1]] = $mapping[2]; } } public function setupUserClasses(&$userTables){ foreach($this->userClasses as $className){ if(!in_array($className, $userTables)){ $userTables[] = $className; } } } public function setupErrorMappings(&$mysqlErrors){ foreach($this->errorMappings as $name=>$desc){ $mysqlErrors[$name] = $desc; } } public function getModelClasses(){ return $this->modelClasses; } protected function addFileFieldMapping($className, $fieldName, $fileTableFieldName){ $this->fileFieldMappings[] = array($className, $fieldName, $fileTableFieldName); } protected function addUserClass($className){ $this->userClasses[] = $className; } protected function addDatabaseErrorMapping($error, $description){ $this->errorMappings[$error] = $description; } protected function addModelClass($className){ $this->modelClasses[] = $className; } }