Skip to content
This repository was archived by the owner on Apr 23, 2025. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@
'OXPS_MODULEGENERATOR_JS_NOTIFICATION_EXAMPLE_MODULE_NAME' => '[TR - MyModule]',
'OXPS_MODULEGENERATOR_JS_NOTIFICATION_EXAMPLE_CONTROLLER_NAME' => '[TR - MyController]',
'OXPS_MODULEGENERATOR_JS_NOTIFICATION_EXAMPLE_MODEL_NAME' => '[TR - MyModel]',
'OXPS_MODULEGENERATOR_JS_NOTIFICATION_EXAMPLE_LIST_NAME' => '[TR - MyList]',
'OXPS_MODULEGENERATOR_JS_NOTIFICATION_EXAMPLE_LIST_NAME' => '[TR - MyModel]',
'OXPS_MODULEGENERATOR_JS_NOTIFICATION_EXAMPLE_WIDGET_NAME' => '[TR - MyWidget]',
'OXPS_MODULEGENERATOR_JS_NOTIFICATION_EXAMPLE_BLOCK_NAME' => '[TR - my_block_name@page/details/inc/myblockname.tpl]',
'OXPS_MODULEGENERATOR_JS_NOTIFICATION_EXAMPLE_SETTING_NAME' => '[TR - MySetting]',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@
'OXPS_MODULEGENERATOR_JS_NOTIFICATION_EXAMPLE_MODULE_NAME' => 'MyModule',
'OXPS_MODULEGENERATOR_JS_NOTIFICATION_EXAMPLE_CONTROLLER_NAME' => 'MyController',
'OXPS_MODULEGENERATOR_JS_NOTIFICATION_EXAMPLE_MODEL_NAME' => 'MyModel',
'OXPS_MODULEGENERATOR_JS_NOTIFICATION_EXAMPLE_LIST_NAME' => 'MyList',
'OXPS_MODULEGENERATOR_JS_NOTIFICATION_EXAMPLE_LIST_NAME' => 'MyModel',
'OXPS_MODULEGENERATOR_JS_NOTIFICATION_EXAMPLE_WIDGET_NAME' => 'MyWidget',
'OXPS_MODULEGENERATOR_JS_NOTIFICATION_EXAMPLE_BLOCK_NAME' => 'my_block_name@page/details/inc/myblockname.tpl',
'OXPS_MODULEGENERATOR_JS_NOTIFICATION_EXAMPLE_SETTING_NAME' => 'MySetting',
Expand Down
7 changes: 6 additions & 1 deletion Core/Helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,12 @@ public function fillTestsFolder(
protected function _getPathInsideModule($sModulePath, $mInnerPath)
{
//cutting the parent class directory (for example /Application/Model/)
$sClassPath = substr($mInnerPath, strpos($mInnerPath, 'source/') + strlen('source/'), strlen($mInnerPath));
if( strpos($mInnerPath, 'source/') == 0){
$sClassPath = $mInnerPath;
}
else {
$sClassPath = substr($mInnerPath, strpos($mInnerPath, 'source/') + strlen('source/'), strlen($mInnerPath));
}

if (!empty($sModulePath.$sClassPath) and $this->getFileSystemHelper()->isDir($sModulePath.$sClassPath)) {
$sPathInsideModule = $sClassPath;
Expand Down
2 changes: 1 addition & 1 deletion Core/Validator.php
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ public function moduleExists($sModuleName)

/** @var FileSystem $oFileSystemHelper */
$oFileSystemHelper = Registry::get(FileSystem::class);

return $oFileSystemHelper->isDir($this->getOxModule()->getVendorPath() . $sModuleName)
&& !empty($sModuleName);
}
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,10 @@ Folders structure, empty classes and metadata generation for new OXID eShop modu
## Screenshots

- Module generator
![module generator](out/pictures/module_generator_zoom.png)
![module generator](out/pictures/newModuleGenerator.png)

- Edit mode
![edit mode](out/pictures/edit_mode.png)
![edit mode](out/pictures/editModeModuleGenerator.png)

## To do and nice to have features for future releases
- Refactor longer classes to move some methods elsewhere
Expand Down
Binary file added out/pictures/editModeModuleGenerator.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed out/pictures/edit_mode.png
Binary file not shown.
Binary file removed out/pictures/moduleGenerator.png
Binary file not shown.
Binary file removed out/pictures/module_generator.png
Binary file not shown.
Binary file removed out/pictures/module_generator_zoom.png
Binary file not shown.
Binary file added out/pictures/newModuleGenerator.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed out/pictures/oxps_module_generator.png
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public function setUp()
parent::setUp();

$this->SUT = $this->getMock(
'Admin_oxpsModuleGenerator',
Admin_oxpsModuleGenerator::class,
array('_Admin_oxpsModuleGenerator_init_parent', '_Admin_oxpsModuleGenerator_render_parent')
);

Expand Down Expand Up @@ -112,7 +112,7 @@ public function testInit()

$oModule = $this->SUT->getModule();

$this->assertInstanceOf('oxpsModuleGeneratorOxModule', $oModule);
$this->assertInstanceOf(OxModule::class, $oModule);
$this->assertSame('test', $oModule->getVendorPrefix());
$this->assertSame(
array(
Expand Down Expand Up @@ -464,7 +464,7 @@ public function testGenerateModule_extendedClassesSet_generateModuleSkeletonWith
{
// Config mock
$this->setRequestParameter('modulegenerator_module_name', 'Extended');
$this->setRequestParameter('modulegenerator_extend_classes', 'oxArticle' . PHP_EOL . 'oxList');
$this->setRequestParameter('modulegenerator_extend_classes', 'oxArticle');

$this->SUT->init();
$this->SUT->generateModule();
Expand All @@ -480,7 +480,6 @@ public function testGenerateModule_extendedClassesSet_generateModuleSkeletonWith
$this->assertFileExists($this->_getTestPath('modules/test/Extended/Core/ExtendedModule.php'));
$this->assertFileExists($this->_getTestPath('modules/test/Extended/Application/translations/de/testExtended_de_lang.php'));
$this->assertFileExists($this->_getTestPath('modules/test/Extended/Application/Model/Article.php'));
$this->assertFileExists($this->_getTestPath('modules/test/Extended/Core/ListModel.php'));

// Check metadata content
include($this->_getTestPath('modules/test/Extended/metadata.php'));
Expand All @@ -490,21 +489,16 @@ public function testGenerateModule_extendedClassesSet_generateModuleSkeletonWith
$this->assertSame(
array(
'OxidEsales\Eshop\Application\Model\Article' => 'Test\Extended\Application\Model\Article',
'OxidEsales\Eshop\Core\Model\ListModel' => 'Test\Extended\Core\ListModel',
),
$aModule['extend']
);
}

// Get mock classes so generated classes has something to extend
$this->getMockBuilder(\Test\Extended\Core\ListModel_parent::class)->getMock();
$this->getMockBuilder(\Test\Extended\Application\Model\Article_parent::class)->getMock();
// Check extended class content
$this->assertFalse(class_exists('\Test\Extended\Core\ListModel'));
$this->assertFalse(class_exists('\Test\Extended\Application\Model\Article'));
include($this->_getTestPath('modules/test/Extended/Core/ListModel.php'));
include($this->_getTestPath('modules/test/Extended/Application/Model/Article.php'));
$this->assertTrue(class_exists('Test\Extended\Core\ListModel'));
$this->assertTrue(class_exists('Test\Extended\Application\Model\Article'));
}

Expand Down Expand Up @@ -576,11 +570,10 @@ public function testGenerateModule_controllersSet_generateModuleSkeletonWithCont
}

// Check controller class content
$this->assertFalse(class_exists('Test\Ctrl1\Application\Controller\Page'));
include($this->_getTestPath('modules/test/Ctrl1/Application/Controller/Page.php'));
require_once($this->_getTestPath('modules/test/Ctrl1/Application/Controller/Page.php'));
$this->assertTrue(class_exists('Test\Ctrl1\Application\Controller\Page'));
$oClass = new Test\Ctrl1\Application\Controller\Page();
$this->assertTrue(method_exists($oClass, Render::class));
$oClass = new \Test\Ctrl1\Application\Controller\Page();
$this->assertTrue(method_exists($oClass, 'render'));
}

public function testGenerateModule_sameControllersSetMultipleTimes_generateModuleSkeletonWithUniqueControllersClasses()
Expand Down Expand Up @@ -685,11 +678,10 @@ public function testGenerateModule_modelsSet_generateModuleSkeletonWithModelsCla
// Check metadata content
include($this->_getTestPath('modules/test/Special/metadata.php'));
$this->assertTrue(isset($aModule));

// Check model class content
$this->assertFalse(class_exists('\Test\Special\Application\Model\Offer'));
include($this->_getTestPath('modules/test/Special/Application/Model/Offer.php'));
$this->assertTrue(class_exists('\Test\Special\Application\Model\Offer'));
require_once($this->_getTestPath('modules/test/Special/Application/Model/Offer.php'));
$this->assertTrue(class_exists('Test\Special\Application\Model\Offer'));
$oClass = new \Test\Special\Application\Model\Offer();
$this->assertTrue(method_exists($oClass, '__construct'));
}
Expand Down Expand Up @@ -787,10 +779,9 @@ public function testGenerateModule_widgetsSet_generateModuleSkeletonWithWidgetsC
}

// Check widget class content
$this->assertFalse(class_exists('test\Wi\Application\Component\Widget\Bar'));
include($this->_getTestPath('modules/test/Wi/Application/Component/Widget/Bar.php'));
require_once($this->_getTestPath('modules/test/Wi/Application/Component/Widget/Bar.php'));
$this->assertTrue(class_exists('Test\Wi\Application\Component\Widget\Bar'));
$oClass = new Test\Wi\Application\Component\Widget\Bar();
$oClass = new \Test\Wi\Application\Component\Widget\Bar();
$this->assertTrue(method_exists($oClass, 'isCacheable'));
}

Expand Down Expand Up @@ -1193,7 +1184,7 @@ public function testGenerateModule_allOptionsSet_generateModuleSkeletonWithAllFe
'email' => 'test@example.com',
'extend' => array(
'OxidEsales\Eshop\Application\Model\Basket' => 'Test\AllThings\Application\Model\Basket',
'OxidEsales\Eshop\Core\Model\ListModel' => 'Test\AllThings\Core\ListModel',
'OxidEsales\Eshop\Core\Model\ListModel' => 'Test\AllThings\Core\Model\ListModel',
),
'controllers' => array(
'test_allthings_view' => 'Test\AllThings\Application\Controller\View',
Expand Down Expand Up @@ -1255,7 +1246,7 @@ public function testGenerateModule_allOptionsSet_generateModuleSkeletonWithAllFe
*/
protected function _getTestPath($sPathSuffix = '')
{
return Registry::getConfig()->getConfigParam('sCompileDir') . DIRECTORY_SEPARATOR .
return Registry::getConfig()->getConfigParam('sCompileDir') .
'test' . DIRECTORY_SEPARATOR . (string) $sPathSuffix;
}
}
Expand Down
Loading