[ Index ] |
|
Code source de Symfony 1.0.0 |
1 <?php 2 /* 3 * $Id: ConditionBase.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 require_once 'phing/ProjectComponent.php'; 23 include_once 'phing/Project.php'; 24 include_once 'phing/tasks/system/AvailableTask.php'; 25 include_once 'phing/tasks/system/condition/Condition.php'; 26 27 /** 28 * Abstract baseclass for the <condition> task as well as several 29 * conditions - ensures that the types of conditions inside the task 30 * and the "container" conditions are in sync. 31 * 32 * @author Hans Lellelid <hans@xmpl.org> 33 * @author Andreas Aderhold <andi@binarycloud.com> 34 * @copyright © 2001,2002 THYRELL. All rights reserved 35 * @version $Revision: 1.16 $ 36 * @package phing.tasks.system.condition 37 */ 38 abstract class ConditionBase extends ProjectComponent implements IteratorAggregate { 39 40 public $conditions = array(); // needs to be public for "inner" class access 41 42 function countConditions() { 43 return count($this->conditions); 44 } 45 46 /** 47 * Required for IteratorAggregate 48 */ 49 function getIterator() { 50 return new ConditionEnumeration($this); 51 } 52 53 function getConditions() { 54 return $this->conditions; 55 } 56 57 /** 58 * @return void 59 */ 60 function addAvailable(AvailableTask $a) { 61 $this->conditions[] = $a; 62 } 63 64 /** 65 * @return NotCondition 66 */ 67 function createNot() { 68 include_once 'phing/tasks/system/condition/NotCondition.php'; 69 $num = array_push($this->conditions, new NotCondition()); 70 return $this->conditions[$num-1]; 71 } 72 73 /** 74 * @return AndCondition 75 */ 76 function createAnd() { 77 include_once 'phing/tasks/system/condition/AndCondition.php'; 78 $num = array_push($this->conditions, new AndCondition()); 79 return $this->conditions[$num-1]; 80 } 81 82 /** 83 * @return OrCondition 84 */ 85 function createOr() { 86 include_once 'phing/tasks/system/condition/OrCondition.php'; 87 $num = array_push($this->conditions, new OrCondition()); 88 return $this->conditions[$num-1]; 89 } 90 91 /** 92 * @return EqualsCondition 93 */ 94 function createEquals() { 95 include_once 'phing/tasks/system/condition/EqualsCondition.php'; 96 $num = array_push($this->conditions, new EqualsCondition()); 97 return $this->conditions[$num-1]; 98 } 99 100 /** 101 * @return OsCondition 102 */ 103 function createOs() { 104 include_once 'phing/tasks/system/condition/OsCondition.php'; 105 $num = array_push($this->conditions, new OsCondition()); 106 return $this->conditions[$num-1]; 107 } 108 109 /** 110 * @return IsFalseCondition 111 */ 112 function createIsFalse() { 113 include_once 'phing/tasks/system/condition/IsFalseCondition.php'; 114 $num = array_push($this->conditions, new IsFalseCondition()); 115 return $this->conditions[$num-1]; 116 } 117 118 /** 119 * @return IsTrueCondition 120 */ 121 function createIsTrue() { 122 include_once 'phing/tasks/system/condition/IsTrueCondition.php'; 123 $num = array_push($this->conditions, new IsTrueCondition()); 124 return $this->conditions[$num-1]; 125 } 126 127 /** 128 * @return ContainsCondition 129 */ 130 function createContains() { 131 include_once 'phing/tasks/system/condition/ContainsCondition.php'; 132 $num = array_push($this->conditions, new ContainsCondition()); 133 return $this->conditions[$num-1]; 134 } 135 136 /** 137 * @return IsSetCondition 138 */ 139 function createIsSet() { 140 include_once 'phing/tasks/system/condition/IsSetCondition.php'; 141 $num = array_push($this->conditions, new IsSetCondition()); 142 return $this->conditions[$num-1]; 143 } 144 145 /** 146 * @return ReferenceExistsCondition 147 */ 148 function createReferenceExists() { 149 include_once 'phing/tasks/system/condition/ReferenceExistsCondition.php'; 150 $num = array_push($this->conditions, new ReferenceExistsCondition()); 151 return $this->conditions[$num-1]; 152 } 153 154 } 155 156 /** 157 * "Inner" class for handling enumerations. 158 * Uses build-in PHP5 iterator support. 159 */ 160 class ConditionEnumeration implements Iterator { 161 162 /** Current element number */ 163 private $num = 0; 164 165 /** "Outer" ConditionBase class. */ 166 private $outer; 167 168 function __construct(ConditionBase $outer) { 169 $this->outer = $outer; 170 } 171 172 public function valid() { 173 return $this->outer->countConditions() > $this->num; 174 } 175 176 function current() { 177 $o = $this->outer->conditions[$this->num]; 178 if ($o instanceof ProjectComponent) { 179 $o->setProject($this->outer->getProject()); 180 } 181 return $o; 182 } 183 184 function next() { 185 $this->num++; 186 } 187 188 function key() { 189 return $this->num; 190 } 191 192 function rewind() { 193 $this->num = 0; 194 } 195 }
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 |