# tasks/ext/CapsuleTask.php

## \AssignedVar
jump to top

Package: phing\tasks\ext

An "inner" class for holding assigned var values.

May be need to expand beyond name/value in the future.

### Properties

`$name= ''`
Details

Type

`$value= ''`
Details

Type

### Methods

`getName( ) : void`

`getValue( ) : void`

`setName( $v ) : void`

Parameters

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

`setValue( $v ) : void`

Parameters

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

## \CapsuleTask
jump to top

Package: phing\tasks\ext

A phing task for generating output by using Capsule.

This is based on the interface to TexenTask from Apache's Velocity engine.

Parent(s)
  \Task < \ProjectComponent
Author
  Hans Lellelid
Copyright
  2001,2002 THYRELL. All rights reserved
Version
  $Id: CapsuleTask.php 843 2010-09-02 14:39:13Z mrook $

### Properties

`array $assignedVars= 'array()'`

Any vars assigned via the build file.

AssignedVar[]
Default value `array()`Details

Type
  array

`\Capsule $context= ''`

Capsule "template" engine.

Details

Type
  \Capsule

`array $contextProperties= ''`

<p> These are properties that are fed into the initial context from a properties file. This is simply a convenient way to set some values that you wish to make available in the context.

These values are not critical, like the template path or output path, but allow a convenient way to set a value that may be specific to a particular generation task.

<

p> For example, if you are generating scripts to allow user to automatically create a database, then you might want the

    $databaseName

to be placed in the initial context so that it is available in a script that might look something like the following:

    #!bin/sh

    echo y | mysqladmin create $databaseName

The value of

    $databaseName

isn't critical to output, and you obviously don't want to change the ant task to simply take a database name. So initial context values can be set with properties file.

Details

Type
  array

`string $controlTemplate= ''`

This is the control template that governs the output.

It may or may not invoke the services of worker templates.

Details

Type
  string

`string $description= ''`
inherited

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

Type
  string
Inherited_from
  \Task::$description

`\Location $location= ''`
inherited

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

Type
  \Location
Inherited_from
  \Task::$location

`string $outputDirectory= ''`

This is where texen will place all the output that is a product of the generation process.

Details

Type
  string

`string $outputFile= ''`

This is the file where the generated text will be placed.

Details

Type
  string

`\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

`\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

`string $templatePath= ''`

This is where Velocity will look for templates using the file template loader.

Details

Type
  string

`\RuntimeConfigurable $wrapper= ''`
inherited

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

Type
  \RuntimeConfigurable
Inherited_from
  \Task::$wrapper

### Methods

`cleanup( ) : void`

A hook method called at the end of {@link #execute()} which can be overridden to perform any necessary cleanup activities (such as the release of database connections, etc.). By default, does nothing.

Throws

Exception | Description
--- | ---
\Exception | Problem cleaning up.

`createAssign( ) : void`

Creates an "AssignedVar" class.

`getContextProperties( ) : \Properties`

Get the context properties that will be fed into the initial context be the generating process starts.

Returns

Type | Description
--- | ---
\Properties |

`getControlTemplate( ) : string`

Get the control template for the generating process.

Returns

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

`getDescription( ) : string`
inherited

Returns the textual description of the task

Inherited from: \Task::getDescription()
Returns

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

`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.

`getOutputDirectory( ) : string`

Get the output directory.

Returns

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

`getOutputFile( ) : string`

Get the output file for the generation process.

Returns

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

`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

`getProject( ) : \Project`
inherited

Returns a reference to current project

Inherited from: \ProjectComponent::getProject()
Returns

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

`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)

`getTemplatePath( ) : string`

Get the path where Velocity will look for templates using the file template loader.

Returns

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

`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 |

`initControlContext( ) : \Smarty`

Creates a Smarty object.

Returns

Type | Description
--- | ---
\Smarty | initialized (cleared) Smarty context.

Throws

Exception | Description
--- | ---
\Exception | the execute method will catch and rethrow as a `BuildException`

`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`

Execute the input script with Velocity

Should throw a BuildException if someting goes wrong with the build

This is abstract here. Must be overloaded by real tasks.

Throws

Exception | Description
--- | ---
\BuildException | BuildExceptions are thrown when required attributes are missing. Exceptions thrown by Velocity are rethrown as BuildExceptions.

`maybeConfigure( ) : void`
inherited

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

Inherited from: \Task::maybeConfigure()
`perform( ) : void`
inherited

Perfrom this task

Inherited from: \Task::perform()
`populateInitialContext( \Capsule $context ) : void`

Place useful objects into the initial context.

Parameters

Name | Type | Description
--- | --- | ---
$context | \Capsule | The context to populate, as retrieved from {@link #initControlContext()}.

Throws

Exception | Description
--- | ---
\Exception | Error while populating context. The {@link #main()} method will catch and rethrow as a `BuildException`.

`setContextProperties( string $file ) : void`

Set the context properties that will be fed into the initial context be the generating process starts.

Parameters

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

`setControlTemplate( string $controlTemplate ) : void`

[REQUIRED] Set the control template for the generating process.

Parameters

Name | Type | Description
--- | --- | ---
$controlTemplate | string |

`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

`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.

`setOutputDirectory( \PhingFile $outputDirectory ) : void`

[REQUIRED] Set the output directory. It will be created if it doesn't exist.

Parameters

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

Throws

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

`setOutputFile( string $outputFile ) : void`

[REQUIRED] Set the output file for the generation process.

Parameters

Name | Type | Description
--- | --- | ---
$outputFile | string | (TODO: change this to File)

`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

`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

`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)

`setTemplatePath( $templatePath ) : void`

[REQUIRED] Set the path where Velocity will look for templates using the file template loader.

Parameters

Name | Type | Description
--- | --- | ---
$templatePath |  |

Throws

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

Documentation was generated by DocBlox 0.15.1.