Phing is nested if conditions

I am having trouble understanding the Phing documentation regarding several conditions for this <if> . This means that you cannot have multiple conditions unless you use the <and> , but there are no examples of how to use it. Therefore, I nested two <if> tags, but I feel stupid when I know that there is a better way. Does anyone know how I can use the <and> tag to do the following:

  <if><equals arg1="${deployment.host.type}" arg2="unrestricted" /><then> <if><equals arg1="${db.adapter}" arg2="PDO_MYSQL"/><then> <!-- Code Here --> </then></if> </then></if> 

It is very surprising to me that no one had experience in this. Phing is an implementation of the ANT 'build tool in PHP instead of Java. This is very useful for PHP developers who lack a simple and powerful deployment tool. Java's ability to pack stand-alone web projects into a single file or a package of multiple web project files into an even larger file is an amazing opportunity. ANT or Phing does not get PHP up to this point, but its a definite step in the right direction, and leaps and bounds are easier to understand and use than GNU Make has ever been or will be.

+4
source share
1 answer

According to the Phing documentation :

<or> the element does not have any attributes, but accepts an arbitrary number of conditions in the form of nested elements . This condition is true if at least one of its contained conditions, conditions will be evaluated in the order in which they were specified in the assembly file.

At first, this may seem confusing, especially without convenient examples, but the keywords that should be noted “accept an arbitrary number of conditions in the form of nested elements”. If you try the next piece of the assembly, you should easily understand how to use <or gt; and <and> Conditions:

 <if> <or> <equals arg1="foo" arg2="bar" /> <equals arg1="baz" arg2="baz" /> </or> <then> <echo message="Foo equals bar, OR baz equals baz!" /> </then> </if> <if> <or> <equals arg1="foo" arg2="bar" /> <equals arg1="baz" arg2="bam" /> </or> <then> <echo message="Foo equals bar, OR baz equals baz!" /> </then> <else> <echo message="No match to OR found." /> </else> </if> <fail /> 
+6
source

Source: https://habr.com/ru/post/1305172/


All Articles