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