[ Index ] |
|
Code source de Symfony 1.0.0 |
1 <?php 2 /* 3 * $Id: RuntimeConfigurable.php 3076 2006-12-18 08:52:12Z fabien $ 4 * 5 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 6 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 7 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 8 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 9 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 10 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 11 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 12 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 13 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 14 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 15 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 16 * 17 * This software consists of voluntary contributions made by many individuals 18 * and is licensed under the LGPL. For more information please see 19 * <http://phing.info>. 20 */ 21 22 /** 23 * Wrapper class that holds the attributes of a Task (or elements 24 * nested below that level) and takes care of configuring that element 25 * at runtime. 26 * 27 * <strong>SMART-UP INLINE DOCS</strong> 28 * 29 * @author Andreas Aderhold <andi@binarycloud.com> 30 * @author Hans Lellelid <hans@xmpl.org> 31 * @version $Revision: 1.6 $ 32 * @package phing 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 /** @param proxy The element to wrap. */ 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 /** Set's the attributes for the wrapped element. */ 54 function setAttributes($attributes) { 55 $this->attributes = $attributes; 56 } 57 58 /** Returns the AttributeList of the wrapped element. */ 59 function getAttributes() { 60 return $this->attributes; 61 } 62 63 /** Adds child elements to the wrapped element. */ 64 function addChild(RuntimeConfigurable $child) { 65 $this->children[] = $child; 66 } 67 68 /** Returns the child with index */ 69 function getChild($index) { 70 return $this->children[(int)$index]; 71 } 72 73 /** Add characters from #PCDATA areas to the wrapped element. */ 74 function addText($data) { 75 $this->characters .= (string) $data; 76 } 77 78 function getElementTag() { 79 return $this->elementTag; 80 } 81 82 83 /** Configure the wrapped element and all children. */ 84 function maybeConfigure(Project $project) { 85 $id = null; 86 87 // DataType configured in ProjectConfigurator 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 // Configure all child of this object ... 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
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Fri Mar 16 22:42:14 2007 | par Balluche grâce à PHPXref 0.7 |