示例#1
0
 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);
 }
示例#2
0
 /**
  * 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();
 }
示例#3
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);
 }
示例#4
0
 /**
  * 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);
 }