# tasks/system/PropertyTask.php

## \PropertyTask
jump to top

Package: phing\tasks\system

Task for setting properties in buildfiles.

Use {@link Project#createTask} to register a new Task.

Parent(s)
  \Task < \ProjectComponent
Children
  \XmlPropertyTask
Author
  Andreas Aderhold
Author
  Hans Lellelid
Copyright
  2001,2002 THYRELL. All rights reserved
Version
  $Revision: 552 $

### Properties

`string $description= ''`
inherited

description of the taskInherited from: \Task::$description
Details

Type
  string
Inherited_from
  \Task::$description

`$env= ''`
Details

Type

`$fallback= ''`
Details

Type

`$file= ''`
Details

Type

`\Location $location= ''`
inherited

stored buildfile locationInherited from: \Task::$location
Details

Type
  \Location
Inherited_from
  \Task::$location

`$name= ''`

name of the property

Details

Type

`$override= 'false'`

Whether to force overwrite of existing property.

Default value `false` Details

Type

`$prefix= ''`
Details

Type

`\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
Default value `null` Details

Type
  \Project
Inherited_from
  \ProjectComponent::$project

`$ref= ''`
Details

Type

`$reference= ''`
Details

Type

`\Target $target= ''`
inherited

owning Target objectInherited from: \Task::$target
Details

Type
  \Target
Inherited_from
  \Task::$target

`string $taskName= ''`
inherited

Taskname for loggerInherited from: \Task::$taskName
Details

Type
  string
Inherited_from
  \Task::$taskName

`string $taskType= ''`
inherited

internal taskname (req)Inherited from: \Task::$taskType
Details

Type
  string
Inherited_from
  \Task::$taskType

`$userProperty= 'false'`

Whether property should be treated as "user" property.

Default value `false` Details

Type

`$value= ''`

value of the property

Details

Type

`\RuntimeConfigurable $wrapper= ''`
inherited

wrapper of the taskInherited from: \Task::$wrapper
Details

Type
  \RuntimeConfigurable
Inherited_from
  \Task::$wrapper

### Methods

`addProperties( $props ) : void`

iterate through a set of properties, resolve them then assign them

Parameters

Name | Type | Description
--- | --- | ---
$props |  |

`addProperty( string $name, string $value ) : void`

add a name value pair to the project property set

Parameters

Name | Type | Description
--- | --- | ---
$name | string | name of property
$value | string | value to set

`addText( $value ) : void`

Sets value of property to CDATA tag contents.

Parameters

Name | Type | Description
--- | --- | ---
$value |  |

Details

Since
  2.2.0

`getDescription( ) : string`
inherited

Returns the textual description of the task

Inherited from: \Task::getDescription()
Returns

Type | Description
--- | ---
string | The text description of the task

`getEnvironment( ) : void`

`getFallback( ) : void`

`getFile( ) : void`

Get the PhingFile that is being used as property source.

`getLocation( ) : \Location`
inherited

Returns the location within the buildfile this task occurs. Used by {@link BuildException} to give detailed error messages.

Inherited from: \Task::getLocation()
Returns

Type | Description
--- | ---
\Location | The location object describing the position of this task within the buildfile.

`getName( ) : void`

Get property component name.

`getOverride( ) : void`

`getOwningTarget( ) : \Target`
inherited

Returns the owning target of this task.

Inherited from: \Task::getOwningTarget()
Returns

Type | Description
--- | ---
\Target | The target object that owns this task

`getPrefix( ) : string`

Returns

Type | Description
--- | ---
string |

Details

Since
  2.0

`getProject( ) : \Project`
inherited

Returns a reference to current project

Inherited from: \ProjectComponent::getProject()
Returns

Type | Description
--- | ---
\Project | Reference to current porject object

`getRefid( ) : void`

`getRegisterSlot( $slotName ) : void`
inherited

Returns a name

Inherited from: \Task::getRegisterSlot()
Parameters

Name | Type | Description
--- | --- | ---
$slotName |  |

`getRuntimeConfigurableWrapper( ) : \RuntimeConfigurable`
inherited

Returns the wrapper object for runtime configuration

Inherited from: \Task::getRuntimeConfigurableWrapper()
Returns

Type | Description
--- | ---
\RuntimeConfigurable | The wrapper object used by this task

`getTaskName( ) : string`
inherited

Returns the name of task, used only for log messages

Inherited from: \Task::getTaskName()
Returns

Type | Description
--- | ---
string | Name of this task

`getTaskType( ) : string`
inherited

Returns the name of the task under which it was invoked, usually the XML tagname

Inherited from: \Task::getTaskType()
Returns

Type | Description
--- | ---
string | The type of this task (XML Tag)

`getUserProperty( ) : void`

`getValue( ) : void`

Get the value of current property component.

`init( ) : void`
inherited

Called by the parser to let the task initialize properly.

Inherited from: \Task::init()

Should throw a BuildException if something goes wrong with the build

This is abstract here, but may not be overloaded by subclasses.

Throws

Exception | Description
--- | ---
\BuildException |

`loadEnvironment( string $prefix ) : void`

load the environment values

Parameters

Name | Type | Description
--- | --- | ---
$prefix | string | prefix to place before them

`loadFile( \PhingFile $file ) : void`

load properties from a file.

Parameters

Name | Type | Description
--- | --- | ---
$file | \PhingFile |

`log( string $msg, integer $level = Project::MSG_INFO ) : void`
inherited

Provides a project level log event to the task.

Inherited from: \Task::log()

@param string $msg The message to be logged.

Parameters

Name | Type | Description
--- | --- | ---
$msg | string | The message to log
$level | integer | The priority of the message

Details

See
  \BuildEvent
See
  \BuildListener

`main( ) : void`

set the property in the project to the value.

if the task was give a file or env attribute here is where it is loaded

`maybeConfigure( ) : void`
inherited

Configure this task if it hasn't been done already.

Inherited from: \Task::maybeConfigure()
`parsePropertyString( string $value, array $fragments, array $propertyRefs ) : void`

This method will parse a string containing ${value} style property values into two lists. The first list is a collection of text fragments, while the other is a set of string property names null entries in the first list indicate a property reference from the second list.

This is slower than regex, but useful for this class, which has to handle multiple parsing passes for properties.

Parameters

Name | Type | Description
--- | --- | ---
$value | string | The string to be scanned for property references
$fragments | array | &$fragments The found fragments
$propertyRefs | array | &$propertyRefs The found refs

`perform( ) : void`
inherited

Perfrom this task

Inherited from: \Task::perform()
`resolveAllProperties( \Properties $props ) : void`

Given a Properties object, this method goes through and resolves any references to properties within the object.

Parameters

Name | Type | Description
--- | --- | ---
$props | \Properties | The collection of Properties that need to be resolved.

`setDescription( string $desc ) : void`
inherited

Sets a textual description of the task

Inherited from: \Task::setDescription()
Parameters

Name | Type | Description
--- | --- | ---
$desc | string | The text describing the task

`setEnvironment( \env $env ) : void`

the prefix to use when retrieving environment variables.

Thus if you specify environment="myenv" you will be able to access OS-specific environment variables via property names "myenv.PATH" or "myenv.TERM".

<

p> Note that if you supply a property name with a final "." it will not be doubled. ie environment="myenv." will still allow access of environment variables through "myenv.PATH" and "myenv.TERM". This functionality is currently only implemented on select platforms. Feel free to send patches to increase the number of platforms this functionality is supported on ;).
Note also that properties are case sensitive, even if the environment variables on your operating system are not, e.g. it will be ${env.Path} not ${env.PATH} on Windows 2000.

Parameters

Name | Type | Description
--- | --- | ---
$env | \env | prefix

`setFallback( \Project $p ) : void`

Parameters

Name | Type | Description
--- | --- | ---
$p | \Project |

`setFile( $file ) : void`

Set a file to use as the source for properties.

Parameters

Name | Type | Description
--- | --- | ---
$file |  |

`setLocation( \Location $location ) : void`
inherited

Sets the location within the buildfile this task occurs. Called by the parser to set location information.

Inherited from: \Task::setLocation()
Parameters

Name | Type | Description
--- | --- | ---
$location | \Location | The location object describing the position of this task within the buildfile.

`setName( $name ) : void`

Sets a the name of current property component

Parameters

Name | Type | Description
--- | --- | ---
$name |  |

`setOverride( $v ) : void`

Parameters

Name | Type | Description
--- | --- | ---
$v |  |

`setOwningTarget( \Target $target ) : void`
inherited

Sets the owning target this task belongs to.

Inherited from: \Task::setOwningTarget()
Parameters

Name | Type | Description
--- | --- | ---
$target | \Target | Reference to owning target

`setPrefix( string $prefix ) : void`

Prefix to apply to properties loaded using `file`.

A "." is appended to the prefix if not specified.

Parameters

Name | Type | Description
--- | --- | ---
$prefix | string | prefix string

Details

Since
  2.0

`setProject( \Project $project ) : void`
inherited

References the project to the current component.

Inherited from: \ProjectComponent::setProject()
Parameters

Name | Type | Description
--- | --- | ---
$project | \Project | The reference to the current project

`setRefid( $ref ) : void`

Parameters

Name | Type | Description
--- | --- | ---
$ref |  |

`setRuntimeConfigurableWrapper( \RuntimeConfigurable $wrapper ) : void`
inherited

Sets the wrapper object this task should use for runtime configurable elements.

Inherited from: \Task::setRuntimeConfigurableWrapper()
Parameters

Name | Type | Description
--- | --- | ---
$wrapper | \RuntimeConfigurable | The wrapper object this task should use

`setTaskName( $name ) : string`
inherited

Sets the name of this task for log messages

Inherited from: \Task::setTaskName()
Parameters

Name | Type | Description
--- | --- | ---
$name |  |

Returns

Type | Description
--- | ---
string | A string representing the name of this task for log

`setTaskType( string $name ) : void`
inherited

Sets the type of the task. Usually this is the name of the XML tag

Inherited from: \Task::setTaskType()
Parameters

Name | Type | Description
--- | --- | ---
$name | string | The type of this task (XML Tag)

`setUserProperty( boolean $v ) : void`

Set whether this is a user property (ro).

This is deprecated in Ant 1.5, but the userProperty attribute of the class is still being set via constructor, so Phing will allow this method to function.

Parameters

Name | Type | Description
--- | --- | ---
$v | boolean |

`setValue( mixed $value ) : void`

Sets a the value of current property component.

Parameters

Name | Type | Description
--- | --- | ---
$value | mixed | Value of name, all scalars allowed

`toString( ) : void`

Documentation was generated by DocBlox 0.15.1.