public function testUpdate() { $segment = $this->createSegment('key', ['nested_key' => 'value']); $preExisting = ['foo' => 'bar', 'key' => 'value', 'baz' => 1]; $this->reader->expects($this->once())->method('load')->willReturn($preExisting); $expected = ['foo' => 'bar', 'key' => ['nested_key' => 'value'], 'baz' => 1]; $this->formatter->expects($this->once())->method('format')->with($expected)->willReturn('formatted'); $this->dirWrite->expects($this->once())->method('writeFile')->with('test.php', 'formatted'); $this->object->update($segment); }
/** * Sets specified modules to enabled or disabled state * * Performs other necessary routines, such as cache cleanup * * @param bool $isEnabled * @param string[] $modules * @return void */ public function setIsEnabled($isEnabled, $modules) { $result = []; foreach ($this->getAllModules($modules) as $name) { $currentStatus = $this->list->has($name); if (in_array($name, $modules)) { $result[$name] = $isEnabled; } else { $result[$name] = $currentStatus; } } $segment = $this->deploymentConfigFactory->create($result); $this->writer->update($segment); $this->cleanup->clearCaches(); $this->cleanup->clearCodeGeneratedFiles(); }
/** * 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); }
/** * Save the current statuses (enabled/disabled) of cache types to the persistent storage * * @return void */ public function persist() { $this->load(); $segment = new ConfigSegment($this->statuses); $this->writer->update($segment); }