1<?php 2 3namespace dokuwiki\plugin\farmsync\meta; 4 5 6class StructUpdates extends EntityUpdates { 7 8 protected $assignments = array(); 9 10 public function updateEntity($struct, $source, $target) { 11 list($schemaName, $json) = $struct; 12 $result = $this->farm_util->updateAnimalStructSchema($target, $schemaName, $json); 13 if (is_a($result, 'dokuwiki\plugin\farmsync\meta\StructConflict')) { 14 $this->results[$target]['failed'][] = $result; 15 } else { 16 $this->results[$target]['passed'][] = $result; 17 } 18 } 19 20 protected function preProcessEntities($struct) { 21 $schemas = array(); 22 foreach ($struct as $entry) { 23 list ($operation, $schemaName) = explode('_', $entry, 2); 24 if ($operation == 'assign') { 25 $this->assignments[] = $schemaName; 26 } 27 if ($operation == 'schema') { 28 $schemas[] = $schemaName; 29 } 30 } 31 32 $this->assignments = $this->farm_util->getAnimalStructAssignments($this->source, $this->assignments); 33 34 $schemas = $this->farm_util->getAnimalStructSchemasJSON($this->source, $schemas); 35 36 array_walk($schemas, function (&$value, $key) {$value = array($key, $value);}); 37 38 return $schemas; 39 } 40 41 public function doPerTargetAction($target) { 42 $this->farm_util->replaceAnimalStructAssignments($target, $this->assignments); 43 } 44 45 46 function printProgressLine($target, $i, $total) { 47 echo sprintf($this->getLang('progress:struct'), $target, $i, $total) . "</br>"; 48 } 49 50 protected function printResultHeading() { 51 echo "<h3>" . $this->getLang('heading:struct') . "</h3>"; 52 } 53} 54