Beispiel #1
0
 /**
  * Search for created and updated properties and use the editor to create or update these entries
  *
  * @param Config     $newconfig  The config representing the state after the change
  * @param Document   $doc
  *
  * @throws ProgrammingError
  */
 protected function diffPropertyUpdates(Config $newconfig, Document $doc)
 {
     foreach ($newconfig->toArray() as $section => $directives) {
         if (!is_array($directives)) {
             Logger::warning('Section-less property ' . (string) $directives . ' was ignored.');
             continue;
         }
         if (!$doc->hasSection($section)) {
             $domSection = new Section($section);
             $doc->addSection($domSection);
         } else {
             $domSection = $doc->getSection($section);
         }
         foreach ($directives as $key => $value) {
             if ($value === null) {
                 continue;
             }
             if ($value instanceof ConfigObject) {
                 throw new ProgrammingError('Cannot diff recursive configs');
             }
             if ($domSection->hasDirective($key)) {
                 $domSection->getDirective($key)->setValue($value);
             } else {
                 $dir = new Directive($key);
                 $dir->setValue($value);
                 $domSection->addDirective($dir);
             }
         }
     }
 }