| 1 |
<?php |
|---|
| 2 |
|
|---|
| 3 |
|
|---|
| 4 |
|
|---|
| 5 |
|
|---|
| 6 |
|
|---|
| 7 |
|
|---|
| 8 |
|
|---|
| 9 |
|
|---|
| 10 |
|
|---|
| 11 |
|
|---|
| 12 |
|
|---|
| 13 |
|
|---|
| 14 |
|
|---|
| 15 |
|
|---|
| 16 |
|
|---|
| 17 |
|
|---|
| 18 |
|
|---|
| 19 |
|
|---|
| 20 |
|
|---|
| 21 |
|
|---|
| 22 |
|
|---|
| 23 |
|
|---|
| 24 |
|
|---|
| 25 |
|
|---|
| 26 |
|
|---|
| 27 |
|
|---|
| 28 |
|
|---|
| 29 |
|
|---|
| 30 |
|
|---|
| 31 |
|
|---|
| 32 |
|
|---|
| 33 |
|
|---|
| 34 |
class RuntimeConfigurable { |
|---|
| 35 |
|
|---|
| 36 |
private $elementTag = null; |
|---|
| 37 |
private $children = array(); |
|---|
| 38 |
private $wrappedObject = null; |
|---|
| 39 |
private $attributes = array(); |
|---|
| 40 |
private $characters = ""; |
|---|
| 41 |
|
|---|
| 42 |
|
|---|
| 43 |
|
|---|
| 44 |
function __construct($proxy, $elementTag) { |
|---|
| 45 |
$this->wrappedObject = $proxy; |
|---|
| 46 |
$this->elementTag = $elementTag; |
|---|
| 47 |
} |
|---|
| 48 |
|
|---|
| 49 |
function setProxy($proxy) { |
|---|
| 50 |
$this->wrappedObject = $proxy; |
|---|
| 51 |
} |
|---|
| 52 |
|
|---|
| 53 |
|
|---|
| 54 |
function setAttributes($attributes) { |
|---|
| 55 |
$this->attributes = $attributes; |
|---|
| 56 |
} |
|---|
| 57 |
|
|---|
| 58 |
|
|---|
| 59 |
function getAttributes() { |
|---|
| 60 |
return $this->attributes; |
|---|
| 61 |
} |
|---|
| 62 |
|
|---|
| 63 |
|
|---|
| 64 |
function addChild(RuntimeConfigurable $child) { |
|---|
| 65 |
$this->children[] = $child; |
|---|
| 66 |
} |
|---|
| 67 |
|
|---|
| 68 |
|
|---|
| 69 |
function getChild($index) { |
|---|
| 70 |
return $this->children[(int)$index]; |
|---|
| 71 |
} |
|---|
| 72 |
|
|---|
| 73 |
|
|---|
| 74 |
function addText($data) { |
|---|
| 75 |
$this->characters .= (string) $data; |
|---|
| 76 |
} |
|---|
| 77 |
|
|---|
| 78 |
function getElementTag() { |
|---|
| 79 |
return $this->elementTag; |
|---|
| 80 |
} |
|---|
| 81 |
|
|---|
| 82 |
|
|---|
| 83 |
|
|---|
| 84 |
function maybeConfigure(Project $project) { |
|---|
| 85 |
$id = null; |
|---|
| 86 |
|
|---|
| 87 |
|
|---|
| 88 |
// if ( is_a($this->wrappedObject, "DataType") ) |
|---|
| 89 |
// return; |
|---|
| 90 |
|
|---|
| 91 |
if ($this->attributes || $this->characters) { |
|---|
| 92 |
ProjectConfigurator::configure($this->wrappedObject, $this->attributes, $project); |
|---|
| 93 |
|
|---|
| 94 |
if (isset($this->attributes["id"])) { |
|---|
| 95 |
$id = $this->attributes["id"]; |
|---|
| 96 |
} |
|---|
| 97 |
|
|---|
| 98 |
$this->attributes = null; |
|---|
| 99 |
|
|---|
| 100 |
if ($this->characters) { |
|---|
| 101 |
ProjectConfigurator::addText($project, $this->wrappedObject, (string) $this->characters); |
|---|
| 102 |
$this->characters=""; |
|---|
| 103 |
} |
|---|
| 104 |
if ($id !== null) { |
|---|
| 105 |
$project->addReference($id, $this->wrappedObject); |
|---|
| 106 |
} |
|---|
| 107 |
} |
|---|
| 108 |
|
|---|
| 109 |
if ( is_array($this->children) && !empty($this->children) ) { |
|---|
| 110 |
|
|---|
| 111 |
foreach($this->children as $child) { |
|---|
| 112 |
$child->maybeConfigure($project); |
|---|
| 113 |
ProjectConfigurator::storeChild($project, $this->wrappedObject, $child->wrappedObject, strtolower($child->getElementTag())); |
|---|
| 114 |
} |
|---|
| 115 |
} |
|---|
| 116 |
} |
|---|
| 117 |
} |
|---|
| 118 |
|
|---|
| 119 |
|
|---|