tasks/system/IfTask.php

Show: inherited
Table of Contents

Perform some tasks based on whether a given condition holds true or not.

This task is heavily based on the Condition framework that can be found in Ant 1.4 and later, therefore it cannot be used in conjunction with versions of Ant prior to 1.4.

This task doesn't have any attributes, the condition to test is specified by a nested element - see the documentation of your

task (see the online documentation for example) for a complete list of nested elements.

Just like the

task, only a single condition can be specified - you combine them using
or
conditions.

In addition to the condition, you can specify three different child elements,

,
and
. All three subelements are optional. Both
and
must not be used more than once inside the if task. Both are containers for Ant tasks, just like Ant's
and
tasks - in fact they are implemented using the same class as Ant's
task.

The

behaves exactly like an

except that it cannot contain the

element inside of it. You may specify as may of these as you like, and the order they are specified is the order they are evaluated in. If the condition on the

is false, then the first

who's conditional evaluates to true will be executed. The

will be executed only if the

and all

conditions are false.

Use the following task to define the

task before you use it the first time:

  <taskdef name="if" classname="net.sf.antcontrib.logic.IfTask" />

Crude Example


 
 
   
 
 
   
 


 
  
 

 
  
  
   
  
 

 
  
 

Author
Stefan Bodewig  
Package
phing.tasks.system  

\ElseIfTask

Package: phing\tasks\system

"Inner" class for IfTask.

This class has same basic structure as the IfTask, although of course it doesn't support tags.

Parent(s)
\ConditionBase < \ProjectComponent
Author
Andreas Aderhold  
Copyright
2001,2002 THYRELL. All rights reserved  
Version
$Id$  

Properties

Propertypublic  $conditions= 'array()'
inheritedInherited from: \ConditionBase::$$conditions
Default valuearray()Details
Type
n/a
Inherited_from
\ConditionBase::$$conditions  
Propertyprotected\Project  $project= 'null'
inherited

Holds a reference to the project that a project component (a task, a target, etc.) belongs to

A reference to the current project instanceInherited from: \ProjectComponent::$$project\ConditionBase::$$project
Default valuenullDetails
Type
\Project
Inherited_from
\ProjectComponent::$$project  
Inherited_from
\ConditionBase::$$project  
Propertyprivate  $thenTasks= 'null'
Default valuenullDetails
Type
n/a

Methods

methodpublicaddAvailable(  $a ) : void
inherited

Inherited from: \ConditionBase::addAvailable()
Parameters
Name Type Description
$a
methodpublicaddThen(  $t ) : void

Parameters
Name Type Description
$t
methodpubliccountConditions( ) : void
inherited

Inherited from: \ConditionBase::countConditions()
methodpubliccreateAnd( ) : \AndCondition
inherited

Inherited from: \ConditionBase::createAnd()
Returns
Type Description
\AndCondition
methodpubliccreateContains( ) : \ContainsCondition
inherited

Inherited from: \ConditionBase::createContains()
Returns
Type Description
\ContainsCondition
methodpubliccreateEquals( ) : \EqualsCondition
inherited

Inherited from: \ConditionBase::createEquals()
Returns
Type Description
\EqualsCondition
methodpubliccreateIsFalse( ) : \IsFalseCondition
inherited

Inherited from: \ConditionBase::createIsFalse()
Returns
Type Description
\IsFalseCondition
methodpubliccreateIsSet( ) : \IsSetCondition
inherited

Inherited from: \ConditionBase::createIsSet()
Returns
Type Description
\IsSetCondition
methodpubliccreateIsTrue( ) : \IsTrueCondition
inherited

Inherited from: \ConditionBase::createIsTrue()
Returns
Type Description
\IsTrueCondition
methodpubliccreateNot( ) : \NotCondition
inherited

Inherited from: \ConditionBase::createNot()
Returns
Type Description
\NotCondition
methodpubliccreateOr( ) : \OrCondition
inherited

Inherited from: \ConditionBase::createOr()
Returns
Type Description
\OrCondition
methodpubliccreateOs( ) : \OsCondition
inherited

Inherited from: \ConditionBase::createOs()
Returns
Type Description
\OsCondition
methodpubliccreateReferenceExists( ) : \ReferenceExistsCondition
inherited

Inherited from: \ConditionBase::createReferenceExists()
Returns
Type Description
\ReferenceExistsCondition
methodpublicevaluate( ) : boolean

Returns
Type Description
boolean
methodpublicgetConditions( ) : void
inherited

Inherited from: \ConditionBase::getConditions()
methodpublicgetIterator( ) : void
inherited

Required for IteratorAggregate

Inherited from: \ConditionBase::getIterator()
methodpublicgetProject( ) : \Project
inherited

Returns a reference to current project

Inherited from: \ProjectComponent::getProject()\ConditionBase::getProject()
Returns
Type Description
\Project Reference to current porject object
methodpubliclog( string $msg, integer $level = Project::MSG_INFO ) : void
inherited

Logs a message with the given priority.

Inherited from: \ProjectComponent::log()\ConditionBase::log()
Parameters
Name Type Description
$msg string

The message to be logged.

$level integer

The message's priority at this message should have

methodpublicmain( ) : void

methodpublicsetProject( \Project $project ) : void
inherited

References the project to the current component.

Inherited from: \ProjectComponent::setProject()\ConditionBase::setProject()
Parameters
Name Type Description
$project \Project

The reference to the current project

\IfTask

Package: phing\tasks\system

Perform some tasks based on whether a given condition holds true or not.

This task is heavily based on the Condition framework that can be found in Ant 1.4 and later, therefore it cannot be used in conjunction with versions of Ant prior to 1.4.

This task doesn't have any attributes, the condition to test is specified by a nested element - see the documentation of your

task (see the online documentation for example) for a complete list of nested elements.

Just like the

task, only a single condition can be specified - you combine them using
or
conditions.

In addition to the condition, you can specify three different child elements,

,
and
. All three subelements are optional. Both
and
must not be used more than once inside the if task. Both are containers for Ant tasks, just like Ant's
and
tasks - in fact they are implemented using the same class as Ant's
task.

The

behaves exactly like an

except that it cannot contain the

element inside of it. You may specify as may of these as you like, and the order they are specified is the order they are evaluated in. If the condition on the

is false, then the first

who's conditional evaluates to true will be executed. The

will be executed only if the

and all

conditions are false.

Use the following task to define the

task before you use it the first time:

  <taskdef name="if" classname="net.sf.antcontrib.logic.IfTask" />

Crude Example


 
 
   
 
 
   
 


 
  
 

 
  
  
   
  
 

 
  
 

Parent(s)
\ConditionBase < \ProjectComponent
Author
Stefan Bodewig  
Copyright
2001,2002 THYRELL. All rights reserved  
Version
$Id$  

Properties

Propertypublic  $conditions= 'array()'
inheritedInherited from: \ConditionBase::$$conditions
Default valuearray()Details
Type
n/a
Inherited_from
\ConditionBase::$$conditions  
Propertyprivate  $elseIfTasks= 'array()'
Default valuearray()Details
Type
n/a
Propertyprivate  $elseTasks= 'null'
Default valuenullDetails
Type
n/a
Propertyprotected\Project  $project= 'null'
inherited

Holds a reference to the project that a project component (a task, a target, etc.) belongs to

A reference to the current project instanceInherited from: \ProjectComponent::$$project\ConditionBase::$$project
Default valuenullDetails
Type
\Project
Inherited_from
\ProjectComponent::$$project  
Inherited_from
\ConditionBase::$$project  
Propertyprivate  $thenTasks= 'null'
Default valuenullDetails
Type
n/a

Methods

methodpublicaddAvailable(  $a ) : void
inherited

Inherited from: \ConditionBase::addAvailable()
Parameters
Name Type Description
$a
methodpublicaddElse(  $e ) : void

A nested element - a container of tasks that will be run if the condition doesn't hold true.

Not required.

Parameters
Name Type Description
$e
methodpublicaddElseIf(  $ei ) : void

Parameters
Name Type Description
$ei
methodpublicaddThen(  $t ) : void

A nested element - a container of tasks that will be run if the condition holds true.

Not required.

Parameters
Name Type Description
$t
methodpubliccountConditions( ) : void
inherited

Inherited from: \ConditionBase::countConditions()
methodpubliccreateAnd( ) : \AndCondition
inherited

Inherited from: \ConditionBase::createAnd()
Returns
Type Description
\AndCondition
methodpubliccreateContains( ) : \ContainsCondition
inherited

Inherited from: \ConditionBase::createContains()
Returns
Type Description
\ContainsCondition
methodpubliccreateEquals( ) : \EqualsCondition
inherited

Inherited from: \ConditionBase::createEquals()
Returns
Type Description
\EqualsCondition
methodpubliccreateIsFalse( ) : \IsFalseCondition
inherited

Inherited from: \ConditionBase::createIsFalse()
Returns
Type Description
\IsFalseCondition
methodpubliccreateIsSet( ) : \IsSetCondition
inherited

Inherited from: \ConditionBase::createIsSet()
Returns
Type Description
\IsSetCondition
methodpubliccreateIsTrue( ) : \IsTrueCondition
inherited

Inherited from: \ConditionBase::createIsTrue()
Returns
Type Description
\IsTrueCondition
methodpubliccreateNot( ) : \NotCondition
inherited

Inherited from: \ConditionBase::createNot()
Returns
Type Description
\NotCondition
methodpubliccreateOr( ) : \OrCondition
inherited

Inherited from: \ConditionBase::createOr()
Returns
Type Description
\OrCondition
methodpubliccreateOs( ) : \OsCondition
inherited

Inherited from: \ConditionBase::createOs()
Returns
Type Description
\OsCondition
methodpubliccreateReferenceExists( ) : \ReferenceExistsCondition
inherited

Inherited from: \ConditionBase::createReferenceExists()
Returns
Type Description
\ReferenceExistsCondition
methodpublicgetConditions( ) : void
inherited

Inherited from: \ConditionBase::getConditions()
methodpublicgetIterator( ) : void
inherited

Required for IteratorAggregate

Inherited from: \ConditionBase::getIterator()
methodpublicgetProject( ) : \Project
inherited

Returns a reference to current project

Inherited from: \ProjectComponent::getProject()\ConditionBase::getProject()
Returns
Type Description
\Project Reference to current porject object
methodpubliclog( string $msg, integer $level = Project::MSG_INFO ) : void
inherited

Logs a message with the given priority.

Inherited from: \ProjectComponent::log()\ConditionBase::log()
Parameters
Name Type Description
$msg string

The message to be logged.

$level integer

The message's priority at this message should have

methodpublicmain( ) : void

methodpublicsetProject( \Project $project ) : void
inherited

References the project to the current component.

Inherited from: \ProjectComponent::setProject()\ConditionBase::setProject()
Parameters
Name Type Description
$project \Project

The reference to the current project

Documentation was generated by DocBlox 0.18.1.