123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119 |
- <?php
- class RuntimeConfigurable {
- private $elementTag = null;
- private $children = array();
- private $wrappedObject = null;
- private $attributes = array();
- private $characters = "";
-
- function __construct($proxy, $elementTag) {
- $this->wrappedObject = $proxy;
- $this->elementTag = $elementTag;
- }
- function setProxy($proxy) {
- $this->wrappedObject = $proxy;
- }
-
- function setAttributes($attributes) {
- $this->attributes = $attributes;
- }
-
- function getAttributes() {
- return $this->attributes;
- }
-
- function addChild(RuntimeConfigurable $child) {
- $this->children[] = $child;
- }
-
- function getChild($index) {
- return $this->children[(int)$index];
- }
-
- function addText($data) {
- $this->characters .= (string) $data;
- }
- function getElementTag() {
- return $this->elementTag;
- }
-
- function maybeConfigure(Project $project) {
- $id = null;
-
-
-
- if ($this->attributes || $this->characters) {
- ProjectConfigurator::configure($this->wrappedObject, $this->attributes, $project);
- if (isset($this->attributes["id"])) {
- $id = $this->attributes["id"];
- }
- $this->attributes = null;
- if ($this->characters) {
- ProjectConfigurator::addText($project, $this->wrappedObject, (string) $this->characters);
- $this->characters="";
- }
- if ($id !== null) {
- $project->addReference($id, $this->wrappedObject);
- }
- }
- if ( is_array($this->children) && !empty($this->children) ) {
-
- foreach($this->children as $child) {
- $child->maybeConfigure($project);
- ProjectConfigurator::storeChild($project, $this->wrappedObject, $child->wrappedObject, strtolower($child->getElementTag()));
- }
- }
- }
- }
|