Esempio n. 1
0
 /**
  * Load the packages information
  *
  * @return void
  */
 private function load()
 {
     if ($this->packageModuleMap === null) {
         $jsonData = $this->reader->getComposerJsonFiles()->toArray();
         foreach (array_keys($this->loader->load()) as $moduleName) {
             $moduleDir = $this->filesystem->getDirectoryRead(\Magento\Framework\App\Filesystem\DirectoryList::ROOT);
             $key = $moduleDir->getRelativePath($this->dirReader->getModuleDir('', $moduleName) . '/composer.json');
             if (isset($jsonData[$key])) {
                 $packageData = \Zend_Json::decode($jsonData[$key]);
                 if (isset($packageData['name'])) {
                     $this->packageModuleMap[$packageData['name']] = $moduleName;
                 }
                 if (isset($packageData['version'])) {
                     $this->modulePackageVersionMap[$moduleName] = $packageData['version'];
                 }
                 if (!empty($packageData['require'])) {
                     $this->requireMap[$moduleName] = array_keys($packageData['require']);
                 }
                 if (!empty($packageData['conflict'])) {
                     $this->conflictMap[$moduleName] = $packageData['conflict'];
                 }
             }
         }
     }
 }
 /**
  * Constructor
  *
  * @param ModuleList $list
  * @param ModuleList\Loader $loader
  * @param PackageInfoFactory $packageInfoFactory
  */
 public function __construct(ModuleList $list, ModuleList\Loader $loader, PackageInfoFactory $packageInfoFactory)
 {
     $this->enabledModuleList = $list->getNames();
     $this->fullModuleList = $loader->load();
     $packageInfo = $packageInfoFactory->create();
     $this->graph = $this->createGraph($packageInfo);
 }
 public function testRemoveModulesFromDeploymentConfig()
 {
     $this->output->expects($this->atLeastOnce())->method('writeln');
     $this->deploymentConfig->expects($this->once())->method('getConfigData')->willReturn(['moduleA' => 1, 'moduleB' => 1, 'moduleC' => 1, 'moduleD' => 1]);
     $this->loader->expects($this->once())->method('load')->willReturn(['moduleC' => [], 'moduleD' => []]);
     $this->writer->expects($this->once())->method('saveConfig')->with([ConfigFilePool::APP_CONFIG => [ConfigOptionsListConstants::KEY_MODULES => ['moduleC' => 1, 'moduleD' => 1]]]);
     $this->moduleRegistryUninstaller->removeModulesFromDeploymentConfig($this->output, ['moduleA', 'moduleB']);
 }
Esempio n. 4
0
 public function getVersion()
 {
     $modules = $this->_loader->load();
     $v = "";
     if (isset($modules['Ebizmarts_MageMonkey'])) {
         $v = $modules['Ebizmarts_MageMonkey']['setup_version'];
     }
     return $v;
 }
Esempio n. 5
0
 public function getVersion()
 {
     $modules = $this->_loader->load();
     $v = "";
     if (isset($modules['SendPulse_Mageia'])) {
         $v = $modules['SendPulse_Mageia']['setup_version'];
     }
     return $v;
 }
Esempio n. 6
0
 /**
  * @expectedException \Exception
  * @expectedExceptionMessage Circular sequence reference from 'b' to 'a'
  */
 public function testLoadCircular()
 {
     $fixture = ['a' => ['name' => 'a', 'sequence' => ['b']], 'b' => ['name' => 'b', 'sequence' => ['a']]];
     $this->dir->expects($this->once())->method('search')->willReturn(['a', 'b']);
     $this->dir->expects($this->exactly(2))->method('readFile')->will($this->returnValueMap([['a', null, null, self::$sampleXml], ['b', null, null, self::$sampleXml]]));
     $this->converter->expects($this->at(0))->method('convert')->willReturn(['a' => $fixture['a']]);
     $this->converter->expects($this->at(1))->method('convert')->willReturn(['b' => $fixture['b']]);
     $object = new Loader($this->filesystem, $this->converter, $this->parser);
     $object->load();
 }
Esempio n. 7
0
 /**
  * Constructor
  *
  * @param ModuleLoader $moduleLoader
  * @param DeploymentConfig $deploymentConfig
  * @param ObjectManagerProvider $objectManagerProvider
  */
 public function __construct(ModuleLoader $moduleLoader, DeploymentConfig $deploymentConfig, ObjectManagerProvider $objectManagerProvider)
 {
     $this->allModules = $moduleLoader->load();
     foreach (array_keys($this->allModules) as $module) {
         $this->allModules[$module]['selected'] = true;
         $this->allModules[$module]['disabled'] = true;
     }
     $this->deploymentConfig = $deploymentConfig;
     $this->dependencyChecker = $objectManagerProvider->get()->get('Magento\\Framework\\Module\\DependencyChecker');
 }
 /**
  * Removes module from deployment configuration
  *
  * @param OutputInterface $output
  * @param string[] $modules
  * @return void
  */
 public function removeModulesFromDeploymentConfig(OutputInterface $output, array $modules)
 {
     $output->writeln('<info>Removing ' . implode(', ', $modules) . ' from module list in deployment configuration</info>');
     $configuredModules = $this->deploymentConfig->getConfigData(\Magento\Framework\Config\ConfigOptionsListConstants::KEY_MODULES);
     $existingModules = $this->loader->load($modules);
     $newModules = [];
     foreach (array_keys($existingModules) as $module) {
         $newModules[$module] = isset($configuredModules[$module]) ? $configuredModules[$module] : 0;
     }
     $this->writer->saveConfig([\Magento\Framework\Config\File\ConfigFilePool::APP_CONFIG => [\Magento\Framework\Config\ConfigOptionsListConstants::KEY_MODULES => $newModules]], true);
 }
Esempio n. 9
0
 public function setUp()
 {
     $this->loader = $this->getMock('Magento\\Framework\\Module\\ModuleList\\Loader', [], [], '', false);
     $this->reader = $this->getMock('Magento\\Framework\\Module\\Dir\\Reader', [], [], '', false);
     $this->loader->expects($this->once())->method('load')->will($this->returnValue(['A' => [], 'B' => [], 'C' => [], 'D' => [], 'E' => []]));
     $composerData = ['A/composer.json' => '{"name":"a", "require":{"b":"0.1"}, "conflict":{"c":"0.1"}, "version":"0.1"}', 'B/composer.json' => '{"name":"b", "require":{"d":"0.3"}, "version":"0.2"}', 'C/composer.json' => '{"name":"c", "require":{"e":"0.1"}, "version":"0.1"}', 'D/composer.json' => '{"name":"d", "conflict":{"c":"0.1"}, "version":"0.3"}', 'E/composer.json' => '{"name":"e", "version":"0.4"}'];
     $fileIteratorMock = $this->getMock('Magento\\Framework\\Config\\FileIterator', [], [], '', false);
     $fileIteratorMock->expects($this->once())->method('toArray')->will($this->returnValue($composerData));
     $this->reader->expects($this->once())->method('getComposerJsonFiles')->will($this->returnValue($fileIteratorMock));
     $this->packageInfo = new PackageInfo($this->loader, $this->reader, new \Magento\Framework\Stdlib\String());
 }
Esempio n. 10
0
 /**
  * @expectedException \Exception
  * @expectedExceptionMessage Circular sequence reference from 'b' to 'a'
  */
 public function testLoadCircular()
 {
     $fixture = ['a' => ['name' => 'a', 'sequence' => ['b']], 'b' => ['name' => 'b', 'sequence' => ['a']]];
     $this->dir->expects($this->once())->method('search')->willReturn(['a', 'b']);
     $this->dir->expects($this->exactly(2))->method('readFile')->will($this->returnValueMap([['a', null, null, self::$sampleXml], ['b', null, null, self::$sampleXml]]));
     $dom = new \PHPUnit_Framework_Constraint_IsInstanceOf('DOMDocument');
     $this->converter->expects($this->at(0))->method('convert')->with($dom)->willReturn(['a' => $fixture['a']]);
     $this->converter->expects($this->at(1))->method('convert')->with($dom)->willReturn(['b' => $fixture['b']]);
     $object = new Loader($this->filesystem, $this->converter);
     $object->load();
 }
 protected function setUp()
 {
     $this->packageInfoMock = $this->getMock('Magento\\Framework\\Module\\PackageInfo', [], [], '', false);
     $requireMap = [['A', ['B']], ['B', ['D', 'E']], ['C', ['E']], ['D', ['A']], ['E', []]];
     $this->packageInfoMock->expects($this->any())->method('getRequire')->will($this->returnValueMap($requireMap));
     $this->packageInfoFactoryMock = $this->getMock('Magento\\Framework\\Module\\PackageInfoFactory', [], [], '', false);
     $this->packageInfoFactoryMock->expects($this->once())->method('create')->will($this->returnValue($this->packageInfoMock));
     $this->listMock = $this->getMock('Magento\\Framework\\Module\\ModuleList', [], [], '', false);
     $this->loaderMock = $this->getMock('Magento\\Framework\\Module\\ModuleList\\Loader', [], [], '', false);
     $this->loaderMock->expects($this->any())->method('load')->will($this->returnValue(['A' => [], 'B' => [], 'C' => [], 'D' => [], 'E' => []]));
 }
 public function aroundSave(\Magento\Config\Model\Config $config, \Closure $proceed)
 {
     $ret = $proceed();
     $sectionId = $config->getSection();
     if ($sectionId == 'mandrill' && !$config->getConfigDataValue('mandrill/general/active')) {
         $modules = $this->_loader->load();
         if (isset($modules['Ebizmarts_AbandonedCart'])) {
             $this->_writer->save(\Ebizmarts\AbandonedCart\Model\Config::ACTIVE, 0, $config->getScope(), $config->getScopeId());
         }
         if (isset($modules['Ebizmarts_AutoResponder'])) {
             $this->_writer->save(\Ebizmarts\AutoResponder\Model\Config::ACTIVE, 0, $config->getScope(), $config->getScopeId());
         }
     }
     return $ret;
 }
Esempio n. 13
0
 /**
  * {@inheritdoc}
  *
  * Note that this triggers loading definitions of all existing modules in the system.
  * Use this method only when you actually need modules' declared meta-information.
  *
  * @see getNames()
  */
 public function getAll()
 {
     if (null === $this->enabled) {
         $all = $this->loader->load();
         if (empty($all)) {
             return [];
             // don't record erroneous value into memory
         }
         $this->enabled = [];
         foreach ($all as $key => $value) {
             if ($this->has($key)) {
                 $this->enabled[$key] = $value;
             }
         }
     }
     return $this->enabled;
 }
Esempio n. 14
0
 /**
  * @expectedException \Exception
  * @expectedExceptionMessage Circular sequence reference from 'b' to 'a'
  */
 public function testLoadCircular()
 {
     $fixture = ['a' => ['name' => 'a', 'sequence' => ['b']], 'b' => ['name' => 'b', 'sequence' => ['a']]];
     $this->converter->expects($this->at(0))->method('convert')->willReturn(['a' => $fixture['a']]);
     $this->converter->expects($this->at(1))->method('convert')->willReturn(['b' => $fixture['b']]);
     $this->registry->expects($this->once())->method('getPaths')->willReturn(['/path/to/a', '/path/to/b']);
     $this->driver->expects($this->exactly(2))->method('fileGetContents')->will($this->returnValueMap([['/path/to/a/etc/module.xml', null, null, self::$sampleXml], ['/path/to/b/etc/module.xml', null, null, self::$sampleXml]]));
     $this->loader->load();
 }
Esempio n. 15
0
 /**
  * @expectedException \Exception
  * @expectedExceptionMessage Circular sequence reference from 'b' to 'a'
  */
 public function testLoadCircular()
 {
     $fixture = ['a' => ['name' => 'a', 'sequence' => ['b']], 'b' => ['name' => 'b', 'sequence' => ['a']]];
     $this->dir->expects($this->once())->method('search')->willReturn(['a', 'b']);
     $this->dir->expects($this->exactly(2))->method('readFile')->will($this->returnValueMap([['a', null, null, self::$sampleXml], ['b', null, null, self::$sampleXml]]));
     $this->converter->expects($this->at(0))->method('convert')->willReturn(['a' => $fixture['a']]);
     $this->converter->expects($this->at(1))->method('convert')->willReturn(['b' => $fixture['b']]);
     $this->registry->expects($this->once())->method('getModulePaths')->willReturn([]);
     $this->loader->load();
 }
Esempio n. 16
0
 /**
  * @param array $expectedAllModules
  * @param array $expectedConfig
  * @param array $expectedResult
  *
  * @dataProvider getAllModulesDataProvider
  */
 public function testSetIsEnabled($expectedAllModules, $expectedConfig, $expectedResult)
 {
     $this->moduleLoader->expects($this->once())->method('load')->will($this->returnValue($expectedAllModules));
     $this->deploymentConfig->expects($this->once())->method('get')->will($this->returnValue($expectedConfig));
     $this->dependencyChecker->expects($this->any())->method('checkDependenciesWhenDisableModules')->willReturn(['module1' => [], 'module2' => [], 'module3' => [], 'module4' => []]);
     $moduleStatus = new ModuleStatus($this->moduleLoader, $this->deploymentConfig, $this->objectManagerProvider);
     $moduleStatus->setIsEnabled(false, 'module1');
     $allModules = $moduleStatus->getAllModules();
     $this->assertSame(false, $allModules['module1']['selected']);
     $this->assertSame($expectedResult[1], $allModules['module2']['selected']);
     $this->assertSame($expectedResult[2], $allModules['module3']['selected']);
     $this->assertSame($expectedResult[3], $allModules['module4']['selected']);
 }
Esempio n. 17
0
 /**
  * Gets all modules and filters against the specified list
  *
  * @param string[] $modules
  * @return string[]
  * @throws \LogicException
  */
 private function getAllModules($modules)
 {
     $all = $this->loader->load();
     $unknown = [];
     foreach ($modules as $name) {
         if (!isset($all[$name])) {
             $unknown[] = $name;
         }
     }
     if ($unknown) {
         throw new \LogicException("Unknown module(s): '" . implode("', '", $unknown) . "'");
     }
     return array_keys($all);
 }
Esempio n. 18
0
 /**
  * Load the packages information
  *
  * @return void
  */
 private function load()
 {
     if ($this->packageModuleMap === null) {
         $jsonData = $this->reader->getComposerJsonFiles()->toArray();
         foreach (array_keys($this->loader->load()) as $moduleName) {
             $key = $this->string->upperCaseWords($moduleName, '_', '/') . '/composer.json';
             if (isset($jsonData[$key])) {
                 $packageData = \Zend_Json::decode($jsonData[$key]);
                 if (isset($packageData['name'])) {
                     $this->packageModuleMap[$packageData['name']] = $moduleName;
                 }
                 if (isset($packageData['version'])) {
                     $this->modulePackageVersionMap[$moduleName] = $packageData['version'];
                 }
                 if (!empty($packageData['require'])) {
                     $this->requireMap[$moduleName] = array_keys($packageData['require']);
                 }
                 if (!empty($packageData['conflict'])) {
                     $this->conflictMap[$moduleName] = $packageData['conflict'];
                 }
             }
         }
     }
 }
Esempio n. 19
0
 /**
  * Prepare mocks for update modules tests and returns the installer to use
  *
  * @return Installer
  */
 private function prepareForUpdateModulesTests()
 {
     $allModules = ['Foo_One' => [], 'Bar_Two' => [], 'New_Module' => []];
     $cacheManager = $this->getMock('Magento\\Framework\\App\\Cache\\Manager', [], [], '', false);
     $cacheManager->expects($this->once())->method('getAvailableTypes')->willReturn(['foo', 'bar']);
     $cacheManager->expects($this->once())->method('clean');
     $this->objectManager->expects($this->any())->method('get')->will($this->returnValueMap([['Magento\\Framework\\App\\Cache\\Manager', $cacheManager]]));
     $this->moduleLoader->expects($this->once())->method('load')->willReturn($allModules);
     $expectedModules = [ConfigFilePool::APP_CONFIG => ['modules' => ['Bar_Two' => 0, 'Foo_One' => 1, 'New_Module' => 1]]];
     $this->config->expects($this->atLeastOnce())->method('isAvailable')->willReturn(true);
     $newObject = $this->createObject(false, false);
     $this->configReader->expects($this->once())->method('load')->willReturn(['modules' => ['Bar_Two' => 0, 'Foo_One' => 1, 'Old_Module' => 0]]);
     $this->configWriter->expects($this->once())->method('saveConfig')->with($expectedModules);
     return $newObject;
 }
Esempio n. 20
0
    public function testUpdateModulesSequence()
    {
        $allModules = [
            'Foo_One' => [],
            'Bar_Two' => [],
            'New_Module' => [],
        ];
        $this->cleanupFiles->expects($this->once())->method('clearCodeGeneratedClasses')->will(
            $this->returnValue(
                [
                    "The directory '/generation' doesn't exist - skipping cleanup",
                ]
            )
        );

        $cache = $this->getMock('Magento\Framework\App\Cache', [], [], '', false);
        $cache->expects($this->once())->method('clean');
        $this->objectManager->expects($this->once())
            ->method('create')
            ->will($this->returnValueMap([
                ['Magento\Framework\App\Cache', [], $cache],
            ]));

        $this->moduleLoader->expects($this->once())->method('load')->willReturn($allModules);

        $expectedModules = [
            ConfigFilePool::APP_CONFIG => [
                'modules' => [
                    'Bar_Two' => 0,
                    'Foo_One' => 1,
                    'New_Module' => 1
                ]
            ]
        ];

        $this->config->expects($this->atLeastOnce())->method('isAvailable')->willReturn(true);

        $newObject = $this->createObject(false, false);
        $this->configReader->expects($this->once())->method('load')
            ->willReturn(['modules' => ['Bar_Two' => 0, 'Foo_One' => 1, 'Old_Module' => 0] ]);
        $this->configWriter->expects($this->once())->method('saveConfig')->with($expectedModules);
        $this->logger->expects($this->at(0))->method('log')->with('Cache cleared successfully');
        $this->logger->expects($this->at(1))->method('log')->with('File system cleanup:');
        $this->logger->expects($this->at(2))->method('log')
            ->with('The directory \'/generation\' doesn\'t exist - skipping cleanup');
        $this->logger->expects($this->at(3))->method('log')->with('Updating modules:');
        $newObject->updateModulesSequence();
    }
Esempio n. 21
0
 public function testUpdateModulesSequence()
 {
     $varDir = $this->getMockForAbstractClass('Magento\\Framework\\Filesystem\\Directory\\WriteInterface');
     $varDir->expects($this->exactly(2))->method('getAbsolutePath')->willReturn('/var');
     $this->filesystem->expects($this->exactly(2))->method('getDirectoryWrite')->willReturn($varDir);
     $allModules = ['Foo_One' => [], 'Bar_Two' => [], 'New_Module' => []];
     $this->moduleLoader->expects($this->once())->method('load')->willReturn($allModules);
     $expectedModules = ['Bar_Two' => 0, 'Foo_One' => 1, 'New_Module' => 1];
     $this->config->expects($this->atLeastOnce())->method('isAvailable')->willReturn(true);
     $this->deploymentConfigFactory->expects($this->once())->method('create')->with($expectedModules)->willReturn($this->deploymentConfig);
     $newObject = $this->createObject(false, false);
     $this->configReader->expects($this->once())->method('load')->willReturn(['modules' => ['Bar_Two' => 0, 'Foo_One' => 1, 'Old_Module' => 0]]);
     $this->configWriter->expects($this->once())->method('update')->with($this->deploymentConfig);
     $this->logger->expects($this->at(0))->method('log')->with('File system cleanup:');
     $this->logger->expects($this->at(1))->method('log')->with('The directory \'/var\' doesn\'t exist - skipping cleanup');
     $this->logger->expects($this->at(3))->method('log')->with('Updating modules:');
     $newObject->updateModulesSequence();
 }
Esempio n. 22
0
 /**
  * @param \Magento\Framework\DataObject $postObject
  *
  * @return bool
  * @throws \Exception
  */
 public function sendrequest($postObject)
 {
     if (!filter_var($postObject->getData('to'), FILTER_VALIDATE_EMAIL)) {
         throw new \Exception($this->_dataHelper->__('Please enter a valid e-mail address.'));
     }
     if (strlen(trim($postObject->getData('replyto')))) {
         if (!filter_var($postObject->getData('replyto'), FILTER_VALIDATE_EMAIL)) {
             throw new \Exception($this->_dataHelper->__('Please enter a valid e-mail address (reply to).'));
         }
         $this->_transportBuilder->setReplyTo(trim($postObject->getData('replyto')));
     }
     $sender = ['name' => $this->_dataHelper->getStoreConfigData('trans_email/ident_general/name'), 'email' => $this->_dataHelper->getStoreConfigData('trans_email/ident_general/email')];
     if (!strlen($sender['email'])) {
         throw new \Exception('Please set your shop e-mail address!');
     }
     $modules = [];
     foreach ($this->_moduleLoader->load() as $module) {
         if (!in_array($module['name'], $this->_moduleBlacklist)) {
             $modules[] = $module['name'];
         }
     }
     natsort($modules);
     $payments = $this->_paymentConfig->getActiveMethods();
     /** @var \Magento\Framework\App\Config\Data $cfg */
     $cfg = $this->_scopePool->getScope(\Magento\Store\Model\ScopeInterface::SCOPE_STORE);
     $foreign = array();
     $mine = array();
     foreach ($payments as $paymentCode => $paymentModel) {
         /** @var AbstractPayment $paymentModel */
         $method = array('label' => $paymentModel->getTitle(), 'value' => $paymentCode, 'config' => []);
         if (preg_match('/^wirecard_/i', $paymentCode)) {
             $method['config'] = $cfg->getValue('payment/' . $paymentCode);
             $mine[$paymentCode] = $method;
         } else {
             $foreign[$paymentCode] = $method;
         }
     }
     $versioninfo = new \Magento\Framework\DataObject();
     $versioninfo->setData($this->_dataHelper->getVersionInfo());
     $transport = $this->_transportBuilder->setTemplateIdentifier('contact_support_email')->setTemplateOptions(['area' => \Magento\Framework\App\Area::AREA_ADMINHTML, 'store' => \Magento\Store\Model\Store::DEFAULT_STORE_ID])->setTemplateVars(['data' => $postObject, 'modules' => $modules, 'foreign' => $foreign, 'mine' => $mine, 'configstr' => $this->_dataHelper->getConfigString(), 'versioninfo' => $versioninfo])->setFrom($sender)->addTo($postObject->getData('to'))->getTransport();
     $transport->sendMessage();
     return true;
 }
Esempio n. 23
0
 /**
  * Creates modules deployment configuration segment
  *
  * @param \ArrayObject|array $request
  * @return DeploymentConfig
  * @throws \LogicException
  */
 private function createModulesConfig($request)
 {
     $all = array_keys($this->moduleLoader->load());
     $enable = $this->readListOfModules($all, $request, self::ENABLE_MODULES) ?: $all;
     $disable = $this->readListOfModules($all, $request, self::DISABLE_MODULES);
     $toEnable = array_diff($enable, $disable);
     if (empty($toEnable)) {
         throw new \LogicException('Unable to determine list of enabled modules.');
     }
     $result = [];
     foreach ($all as $module) {
         $key = array_search($module, $toEnable);
         $result[$module] = false !== $key;
     }
     return new DeploymentConfig($result);
 }
Esempio n. 24
0
 /**
  * Removes module from deployment configuration
  *
  * @param string[] $modules
  * @return void
  */
 private function removeModulesFromDeploymentConfig(array $modules)
 {
     $existingModules = $this->deploymentConfig->getConfigData(ConfigOptionsListConstants::KEY_MODULES);
     $newSort = $this->loader->load($modules);
     $newModules = [];
     foreach (array_keys($newSort) as $module) {
         $newModules[$module] = $existingModules[$module];
     }
     $this->writer->saveConfig(
         [ConfigFilePool::APP_CONFIG => [ConfigOptionsListConstants::KEY_MODULES => $newModules]],
         true
     );
 }
Esempio n. 25
0
 /**
  * Creates modules deployment configuration segment
  *
  * @param \ArrayObject|array $request
  * @return array
  * @throws \LogicException
  */
 private function createModulesConfig($request)
 {
     $all = array_keys($this->moduleLoader->load());
     $currentModules = [];
     if ($this->deploymentConfig->isAvailable()) {
         $deploymentConfig = $this->deploymentConfigReader->load();
         $currentModules = isset($deploymentConfig['modules']) ? $deploymentConfig['modules'] : [];
     }
     $enable = $this->readListOfModules($all, $request, self::ENABLE_MODULES);
     $disable = $this->readListOfModules($all, $request, self::DISABLE_MODULES);
     $result = [];
     foreach ($all as $module) {
         if (isset($currentModules[$module]) && !$currentModules[$module]) {
             $result[$module] = 0;
         } else {
             $result[$module] = 1;
         }
         if (in_array($module, $disable)) {
             $result[$module] = 0;
         }
         if (in_array($module, $enable)) {
             $result[$module] = 1;
         }
     }
     $this->deploymentConfigWriter->saveConfig([ConfigFilePool::APP_CONFIG => ['modules' => $result]], true);
     return $result;
 }
Esempio n. 26
0
 /**
  * Updates modules in deployment configuration
  *
  * @return void
  */
 public function updateModulesSequence()
 {
     $this->assertDeploymentConfigExists();
     $this->log->log('File system cleanup:');
     $this->deleteDirContents(DirectoryList::GENERATION);
     $this->deleteDirContents(DirectoryList::CACHE);
     $this->log->log('Updating modules:');
     $allModules = array_keys($this->moduleLoader->load());
     $deploymentConfig = $this->deploymentConfigReader->load();
     $currentModules = isset($deploymentConfig['modules']) ? $deploymentConfig['modules'] : [];
     $result = [];
     foreach ($allModules as $module) {
         if (isset($currentModules[$module]) && !$currentModules[$module]) {
             $result[$module] = 0;
         } else {
             $result[$module] = 1;
         }
     }
     $segment = $this->deploymentConfigFactory->create($result);
     $this->deploymentConfigWriter->update($segment);
 }
 /**
  * Creates modules deployment configuration segment
  *
  * @param \ArrayObject|array $request
  * @param bool $dryRun
  * @return array
  * @throws \LogicException
  */
 private function createModulesConfig($request, $dryRun = false)
 {
     $all = array_keys($this->moduleLoader->load());
     $deploymentConfig = $this->deploymentConfigReader->load();
     $currentModules = isset($deploymentConfig[ConfigOptionsListConstants::KEY_MODULES])
         ? $deploymentConfig[ConfigOptionsListConstants::KEY_MODULES] : [] ;
     $enable = $this->readListOfModules($all, $request, self::ENABLE_MODULES);
     $disable = $this->readListOfModules($all, $request, self::DISABLE_MODULES);
     $result = [];
     foreach ($all as $module) {
         if ((isset($currentModules[$module]) && !$currentModules[$module])) {
             $result[$module] = 0;
         } else {
             $result[$module] = 1;
         }
         if (in_array($module, $disable)) {
             $result[$module] = 0;
         }
         if (in_array($module, $enable)) {
             $result[$module] = 1;
         }
     }
     if (!$dryRun) {
         $this->deploymentConfigWriter->saveConfig([ConfigFilePool::APP_CONFIG => ['modules' => $result]], true);
     }
     return $result;
 }
    private function setUpExecute($input)
    {
        $this->setUpPassValidation();
        $this->remove->expects($this->once())->method('remove')->with(['magento/package-a', 'magento/package-b']);
        $this->dependencyChecker->expects($this->once())
            ->method('checkDependenciesWhenDisableModules')
            ->willReturn(['Magento_A' => [], 'Magento_B' => []]);
        $this->dataSetup->expects($this->exactly(count($input['module'])))->method('deleteTableRow');
        $this->deploymentConfig->expects($this->once())
            ->method('getConfigData')
            ->with(ConfigOptionsListConstants::KEY_MODULES)
            ->willReturn(['Magento_A' => 1, 'Magento_B' => 1, 'Magento_C' => 0, 'Magento_D' => 1]);

        $this->loader->expects($this->once())
            ->method('load')
            ->with($input['module'])
            ->willReturn(['Magento_C' => [], 'Magento_D' => []]);
        $this->writer->expects($this->once())
            ->method('saveConfig')
            ->with(
                [
                    ConfigFilePool::APP_CONFIG =>
                        [ConfigOptionsListConstants::KEY_MODULES => ['Magento_C' => 0, 'Magento_D' => 1]]
                ]
            );
        $this->cache->expects($this->once())->method('clean');
        $this->cleanupFiles->expects($this->once())->method('clearCodeGeneratedClasses');

    }