Exemple #1
0
 /**
  * @param array $hash
  */
 private function _writeToComposerFile(array $hash)
 {
     $composerFile = new Composer\Json\JsonFile($this->_installation->getDirRoot() . 'composer.json');
     $configCurrent = $composerFile->read();
     $this->_filesystemHelper->notify('modify', 'composer.json');
     $configMerged = $this->_mergeConfigs($configCurrent, $hash);
     $composerFile->write($configMerged);
     $this->_installation->reload();
 }
Exemple #2
0
 /**
  * @param CM_File        $configFile
  * @param CM_Config_Node $config
  */
 private function _appendEntries(CM_File $configFile, CM_Config_Node $config)
 {
     $declarations = $this->_getConfigContent($configFile);
     $exportedValues = $this->_export($config);
     if (!$exportedValues) {
         return;
     }
     $declarations .= '    ' . PHP_EOL;
     foreach ($exportedValues as $key => $value) {
         $valueBlock = new \CodeGenerator\ValueBlock($value);
         $declarations .= '    $config->' . $key . ' = ' . $valueBlock->dump() . ';' . PHP_EOL;
     }
     $functionBlock = new \CodeGenerator\FunctionBlock();
     $functionBlock->setCode($declarations);
     $functionBlock->addParameter(new \CodeGenerator\ParameterBlock('config', 'CM_Config_Node'));
     $content = join(PHP_EOL, ['<?php', '', 'return ' . $functionBlock->dump() . ';']);
     $configFile->ensureParentDirectory();
     $configFile->write($content);
     $this->_filesystemHelper->createFile($configFile, $content, true);
 }