Beispiel #1
0
 public function exportModules($data)
 {
     $moduleTables = $this->getModuleTables();
     $configs = [];
     if (!empty($data['modules'])) {
         $store = $this->_storeManager->getStore($data['store_id']);
         foreach ($data['modules'] as $k => $v) {
             if (isset($moduleTables[$v])) {
                 $tables = $moduleTables[$v];
             }
             $systemFileDir = $this->_moduleDir->getDir($v, Dir::MODULE_ETC_DIR) . DIRECTORY_SEPARATOR . 'adminhtml' . DIRECTORY_SEPARATOR . 'system.xml';
             if (file_exists($systemFileDir)) {
                 $systemConfigs = $this->parser->load($systemFileDir)->xmlToArray();
                 if ($systemConfigs['config']['_value']['system']['section']) {
                     foreach ($systemConfigs['config']['_value']['system']['section'] as $_section) {
                         $groups = [];
                         if (isset($_section['_value']['group'])) {
                             $groups = $_section['_value']['group'];
                         } elseif (isset($_section['group'])) {
                             $groups = $_section['group'];
                         }
                         $_sectionId = '';
                         if (isset($_section['_attribute']['id'])) {
                             $_sectionId = $_section['_attribute']['id'];
                         } elseif (isset($systemConfigs['config']['_value']['system']['section']['_attribute']['id'])) {
                             $_sectionId = $systemConfigs['config']['_value']['system']['section']['_attribute']['id'];
                         }
                         if (empty($groups)) {
                             continue;
                         }
                         foreach ($groups as $_group) {
                             if (!isset($_group['_value']['field'])) {
                                 continue;
                             }
                             foreach ($_group['_value']['field'] as $_field) {
                                 if (isset($_sectionId) && isset($_group['_attribute']['id']) && isset($_field['_attribute']['id'])) {
                                     $key = $_sectionId . '/' . $_group['_attribute']['id'] . '/' . $_field['_attribute']['id'];
                                     $result = $this->_scopeConfig->getValue($key, \Magento\Store\Model\ScopeInterface::SCOPE_STORE, $store);
                                     if ($result == '') {
                                         continue;
                                     }
                                     $configs[$v]['system_configs'][] = ['key' => $key, 'value' => $result];
                                 }
                             }
                         }
                     }
                 }
             }
             if (isset($moduleTables[$v]) && is_array($moduleTables[$v])) {
                 foreach ($moduleTables[$v] as $key => $tableName) {
                     $connection = $this->_resource->getConnection();
                     $select = 'SELECT * FROM ' . $this->_resource->getTableName($tableName);
                     $rows = $connection->fetchAll($select);
                     $configs[$v]['tables'][$tableName] = $rows;
                 }
             }
         }
     }
     return $configs;
 }
 /**
  * Retrieve fully-qualified module name, path belongs to
  *
  * @param string $path Full path to file or directory
  * @return string|null
  */
 public function getModuleName($path)
 {
     $path = str_replace('\\', '/', $path);
     foreach ($this->_moduleList->getNames() as $moduleName) {
         $moduleDir = $this->_moduleDirs->getDir($moduleName);
         $moduleDir = str_replace('\\', '/', $moduleDir);
         if ($path == $moduleDir || strpos($path, $moduleDir . '/') === 0) {
             return $moduleName;
         }
     }
     return null;
 }
Beispiel #3
0
 /**
  * Get module directory by directory type
  *
  * @param string $type
  * @param string $moduleName
  * @return string
  */
 public function getModuleDir($type, $moduleName)
 {
     if (isset($this->customModuleDirs[$moduleName][$type])) {
         return $this->customModuleDirs[$moduleName][$type];
     }
     return $this->moduleDirs->getDir($moduleName, $type);
 }
Beispiel #4
0
 /**
  * @expectedException \InvalidArgumentException
  * @expectedExceptionMessage Directory type 'unknown' is not recognized
  */
 public function testGetDirModuleSubDirUnknown()
 {
     $this->_model->getDir('Test_Module', 'unknown');
 }
Beispiel #5
0
 /**
  * @expectedException \InvalidArgumentException
  * @expectedExceptionMessage Directory type 'unknown' is not recognized
  */
 public function testGetDirModuleSubDirUnknown()
 {
     $this->moduleRegistryMock->expects($this->once())->method('getPath')->with(ComponentRegistrar::MODULE, 'Test_Module')->will($this->returnValue('/Test/Module'));
     $this->_model->getDir('Test_Module', 'unknown');
 }
 /**
  * @param string $path
  * @param string $expectedResult
  * @dataProvider getModuleNameDataProvider
  */
 public function testGetModuleName($path, $expectedResult)
 {
     $this->_moduleList->expects($this->once())->method('getNames')->will($this->returnValue(['Fixture_ModuleOne', 'Fixture_ModuleTwo']));
     $this->_moduleDirs->expects($this->atLeastOnce())->method('getDir')->will($this->returnValueMap([['Fixture_ModuleOne', '', 'app/code/Fixture/ModuleOne'], ['Fixture_ModuleTwo', '', 'app/code/Fixture/ModuleTwo']]));
     $this->assertSame($expectedResult, $this->_model->getModuleName($path));
 }
Beispiel #7
0
 /**
  * @expectedException \InvalidArgumentException
  * @expectedExceptionMessage Directory type 'unknown' is not recognized
  */
 public function testGetDirModuleSubDirUnknown()
 {
     $this->_stringMock->expects($this->once())->method('upperCaseWords')->will($this->returnValue('Test/Module'));
     $this->_model->getDir('Test_Module', 'unknown');
 }