/** * @test * @group library */ public function test_getById_success() { // ARRANGE $dao = $this->createModuleDao(); $sources = $this->getModuleSourceItemsFromGlobalSetAndPackage('module_test', 'rz_testing'); $moduleSource = new ModuleSource($this->websiteId, $sources); $expectedModuleId = 'rz_tests_module_only_global'; $expectedModule = new DataModule(); $expectedModule->setSourceType(DataModule::SOURCE_REPOSITORY); $expectedModule->setOverwritten(false); $expectedModule->setId($expectedModuleId); $expectedModule->setName('this is the name: rz_tests_module_only_global (global)'); $expectedModule->setDescription(''); $expectedModule->setVersion('test'); $expectedModule->setIcon('application.png'); $expectedModule->setCategory('{"de":"Default Module","en":"Default Modules"}'); $expectedModule->setModuletype('default'); $expectedModule->setAllowedchildmoduletype('*'); $expectedModule->setRerenderrequired(true); $expectedModule->setApiType('APIv1'); $expectedModule->setSessionRequired(true); // ACT $module = $dao->getById($moduleSource, $expectedModuleId); // ASSERT $this->assertSame($expectedModule->getId(), $module->getId()); $this->assertSame($expectedModule->getSourceType(), $module->getSourceType()); $this->assertSame($expectedModule->isOverwritten(), $module->isOverwritten()); $this->assertSame($expectedModule->getName(), $module->getName()); $this->assertSame($expectedModule->getDescription(), $module->getDescription()); $this->assertSame($expectedModule->getVersion(), $module->getVersion()); $this->assertSame($expectedModule->getIcon(), $module->getIcon()); $this->assertSame($expectedModule->getCategory(), $module->getCategory()); $this->assertSame($expectedModule->getModuletype(), $module->getModuletype()); $this->assertSame($expectedModule->getAllowedchildmoduletype(), $module->getAllowedchildmoduletype()); $this->assertSame($expectedModule->getRerenderrequired(), $module->getRerenderrequired()); $this->assertSame($expectedModule->getApiType(), $module->getApiType()); $this->assertSame($expectedModule->getSessionRequired(), $module->getSessionRequired()); }
/** * @param string $websiteId * @param DataModule $module * * @return SourceItem */ protected function createSourceItemForNewModule($websiteId, DataModule $module) { $moduleId = $module->getId(); if (empty($moduleId)) { $module->setNewGeneratedId(); $moduleId = $module->getId(); } $baseDirectory = $this->getWebsiteModulesDataDirectory($websiteId); $baseUrl = $this->getWebsiteModulesUrl($websiteId); return new SourceItem($moduleId, FS::joinPath($baseDirectory, $moduleId), $baseUrl . '/' . $moduleId, SourceItem::SOURCE_LOCAL, false, true); }
/** * @param $data */ protected function setValuesFromData(Data\Modul $data) { $this->setId($data->getId()); $this->setWebsiteid($data->getWebsiteId()); $this->setName($data->getName()); $this->setDescription($data->getDescription()); $this->setVersion($data->getVersion()); $this->setIcon($data->getIcon()); $this->setForm($data->getForm()); $this->setFormvalues($data->getFormvalues()); $this->setCategory($data->getCategory()); $this->setModuletype($data->getModuletype()); $this->setAllowedchildmoduletype($data->getAllowedchildmoduletype()); $this->setReRenderRequired($data->getRerenderrequired()); $this->setSourceType($data->getSourceType()); $this->setOverwritten($data->isOverwritten()); $this->setGhostContainerMode($data->getGhostContainerMode()); }
/** * @param \Cms\Service\Modul $moduleService * @param DataModule $module * @param string $importModuleDataDirectoryPath */ protected function replaceTranslationFile($moduleService, DataModule $module, $importModuleDataDirectoryPath) { $importTranslationFile = FS::joinPath($importModuleDataDirectoryPath, 'moduleTranslation.php'); if (is_readable($importTranslationFile)) { $dataPath = $moduleService->getDataPath($module->getWebsiteid(), $module->getId()); $moduleTranslationFile = FS::joinPath($dataPath, 'moduleTranslation.php'); FS::copyFile($importTranslationFile, $moduleTranslationFile); } }
/** * Copies the whole module to the export module directory * @param DataModule $module */ private function copyModule($module) { $moduleDirectory = $module->getSource()->getDirectory(); $exportModuleDirectory = $this->getExportModuleDirectory($module->getId()); if (!is_dir($moduleDirectory)) { Registry::getLogger()->log(__CLASS__, __METHOD__, sprintf("Error exporting module '%s/%s'. Module source directory '%s' not exists.", $module->getWebsiteid(), $module->getId(), $moduleDirectory), SbLog::ERR); return; } FS::createDirIfNotExists($exportModuleDirectory, true); FS::copyDir($moduleDirectory, $exportModuleDirectory); }