Beispiel #1
0
 /**
  * @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());
 }
Beispiel #2
0
 /**
  * @param string     $websiteId
  * @param string     $moduleId
  * @param SourceItem $sourceItem
  * @param \stdClass  $moduleManifest
  * @param \stdClass  $moduleForm
  * @param \stdClass  $moduleCustomData
  * @param integer    $moduleLastUpdate
  *
  * @return DataModule
  */
 protected function loadDataObject($websiteId, $moduleId, SourceItem $sourceItem, $moduleManifest, $moduleForm, $moduleCustomData, $moduleLastUpdate)
 {
     $module = new DataModule();
     $module->setId($moduleId);
     $module->setWebsiteid($websiteId);
     $module->setCustomData($moduleCustomData);
     $module->setLastUpdate($moduleLastUpdate);
     $module->setSource($sourceItem);
     $module->setSourceType($sourceItem->getType());
     $module->setOverwritten($sourceItem->isOverwritten());
     if (property_exists($moduleManifest, 'name')) {
         $module->setName($moduleManifest->name);
     }
     if (property_exists($moduleManifest, 'description')) {
         $module->setDescription($moduleManifest->description);
     }
     if (property_exists($moduleManifest, 'version')) {
         $module->setVersion($moduleManifest->version);
     }
     if (property_exists($moduleManifest, 'icon')) {
         $module->setIcon($moduleManifest->icon);
     }
     if (property_exists($moduleManifest, 'category')) {
         $module->setCategory($moduleManifest->category);
     }
     if (property_exists($moduleManifest, 'moduleType')) {
         $module->setModuletype($moduleManifest->moduleType);
     }
     if (property_exists($moduleManifest, 'allowedChildModuleType')) {
         $module->setAllowedchildmoduletype($moduleManifest->allowedChildModuleType);
     }
     if (property_exists($moduleManifest, 'reRenderRequired')) {
         $module->setRerenderrequired($moduleManifest->reRenderRequired);
     }
     if (property_exists($moduleManifest, 'ghostContainerMode')) {
         $module->setGhostContainerMode($moduleManifest->ghostContainerMode);
     }
     if (property_exists($moduleForm, 'form')) {
         $module->setForm($moduleForm->form);
     }
     if (property_exists($moduleForm, 'formValues')) {
         $module->setFormvalues($moduleForm->formValues);
     }
     if (property_exists($moduleManifest, 'apiType')) {
         $module->setApiType($moduleManifest->apiType);
     }
     if (property_exists($moduleManifest, 'sessionRequired')) {
         $module->setSessionRequired($moduleManifest->{'sessionRequired'});
     }
     return $module;
 }
 /**
  * @param string $moduleId
  * @param array  $defaultModuleValues
  *
  * @return ModuleData
  */
 protected function createModuleData($moduleId, array $defaultModuleValues)
 {
     $module = new ModuleData();
     $module->setId($moduleId);
     $module->setFormvalues((object) $defaultModuleValues);
     return $module;
 }
Beispiel #4
0
 /**
  * @param  string  $websiteId     Website to import into
  * @param  boolean $checkConflict Check conflict
  * @param  array   $overwriteIds  ModuleIds to overwrite
  *
  * @return array
  */
 private function importModule($websiteId, $checkConflict = false, array $overwriteIds = array())
 {
     $modulesUnzipDirectory = $this->currentImportUnzipDirectory . DIRECTORY_SEPARATOR . 'modules';
     $importedModules = array();
     $conflictingModuleIds = array();
     if ($checkConflict && isset($this->currentConflictItems['modules'])) {
         $conflictingModuleIds = array_keys($this->currentConflictItems['modules']);
     }
     $moduleService = $this->getModuleService();
     // Iterate over all Module
     foreach ($this->currentImportModuleInfo as $currentModuleId => $moduleInfo) {
         $importModulePathName = FS::joinPath($modulesUnzipDirectory, $currentModuleId);
         $importModuleAssetsPath = FS::joinPath($importModulePathName, ExportBusiness::MODULE_SUBDIR_ASSETS);
         $importModuleDataDirectoryPath = FS::joinPath($importModulePathName, ExportBusiness::MODULE_SUBDIR_DATA);
         // check if import of the current module is allowed
         $importCurrentModule = $this->itemImportAllowed($currentModuleId, $conflictingModuleIds, $overwriteIds);
         if (!$importCurrentModule) {
             continue;
         }
         // ### Module till v1.4.0 [use module.json for versions < 1.5.0]
         if (version_compare('1.5.0', $this->getImportVersion()) > 0) {
             $importModuleInfoFile = FS::joinPath($importModulePathName, 'modul.json');
             if (!is_readable($importModuleInfoFile)) {
                 continue;
             }
             $createdModule = $this->createOrOverwriteModuleFromModuleJson($moduleService, $currentModuleId, $websiteId, $importModuleInfoFile);
             $this->replaceModuleAssetFiles($moduleService, $createdModule, $importModuleAssetsPath);
             $this->replaceTranslationFile($moduleService, $createdModule, $importModuleDataDirectoryPath);
         } else {
             // ### Module v1.5.0
             if (!is_dir($importModuleDataDirectoryPath)) {
                 continue;
             }
             $newModule = new DataModule();
             $newModule->setId($currentModuleId);
             $createdModule = $this->createOrOverwriteModule($moduleService, $websiteId, $newModule);
             $this->replaceModuleDataFiles($moduleService, $createdModule, $importModuleDataDirectoryPath);
             $this->replaceModuleAssetFiles($moduleService, $createdModule, $importModuleAssetsPath);
         }
         // we have copy module files -> reset the module cache to ensure that we have the new module attributes
         $moduleService->resetCache();
         $importedModules[] = array('id' => $createdModule->getId(), 'name' => $createdModule->getName());
     }
     return $importedModules;
 }
Beispiel #5
0
 /**
  * @param string $websiteId
  * @param string $moduleId
  * @param array  $attributes
  *
  * @return ModulData
  */
 protected function createModuleDataObject($websiteId, $moduleId, array $attributes = array())
 {
     $module = new ModulData();
     $module->setWebsiteid($websiteId);
     $module->setId($moduleId);
     if (array_key_exists('name', $attributes)) {
         $module->setName($attributes['name']);
     }
     if (array_key_exists('moduleType', $attributes)) {
         $module->setModuletype($attributes['moduleType']);
     }
     if (array_key_exists('form', $attributes)) {
         $module->setForm($attributes['form']);
     }
     if (array_key_exists('formValues', $attributes)) {
         $module->setFormvalues($attributes['formValues']);
     }
     return $module;
 }