PEAR
[ class tree: PEAR ] [ index: PEAR ] [ all elements ]

Class: PEAR_Task_Common

Source Location: /PEAR-1.9.4/PEAR/Task/Common.php

Class Overview


A task is an operation that manipulates the contents of a file.


Author(s):

Version:

  • Release: 1.9.4

Copyright:

  • 1997-2009 The Authors

Variables

Methods


Child classes:

PEAR_Task_Postinstallscript
Implements the postinstallscript file task.
PEAR_Task_Windowseol
Implements the windows line endsings file task.
PEAR_Task_Replace
Implements the replace file task.
PEAR_Task_Unixeol
Implements the unix line endings file task.

Inherited Variables

Inherited Methods


Class Details

[line 55]
A task is an operation that manipulates the contents of a file.

Simple tasks operate on 1 file. Multiple tasks are executed after all files have been processed and installed, and are designed to operate on all files containing the task. The Post-install script task simply takes advantage of the fact that it will be run after installation, replace is a simple task.

Combining tasks is possible, but ordering is significant.

<file name="test.php" role="php"> <tasks:replace from="@data-dir@" to="data_dir" type="pear-config"/> <tasks:postinstallscript/> </file>

This will first replace any instance of @data-dir@ in the test.php file with the path to the current data directory. Then, it will include the test.php file and run the script it contains to configure the package post-installation.



[ Top ]


Class Variables

$config =

[line 75]

  • Access: protected

Type:   mixed


[ Top ]

$installphase =

[line 87]

  • Access: protected

Type:   mixed


[ Top ]

$logger =

[line 83]

  • Access: protected

Type:   mixed


[ Top ]

$phase =  PEAR_TASK_INSTALL

[line 71]

Determines which install phase this task is executed under

Type:   mixed


[ Top ]

$registry =

[line 79]

  • Access: protected

Type:   mixed


[ Top ]

$type =  'simple'

[line 67]

Valid types for this version are 'simple' and 'multiple'

  • simple tasks operate on the contents of a file and write out changes to disk
  • multiple tasks operate on the contents of many files and write out the changes directly to disk
Child task classes must override this property.

  • Access: protected

Type:   mixed


[ Top ]



Method Detail

PEAR_Task_Common (Constructor)   [line 92]

PEAR_Task_Common PEAR_Task_Common( PEAR_Config &$config, PEAR_Common &$logger, $phase)


Parameters:

PEAR_Config   &$config     
PEAR_Common   &$logger     
   $phase     

[ Top ]

hasPostinstallTasks   [line 166]

void hasPostinstallTasks( )

  • Final:

[ Top ]

init   [line 129]

void init( array $xml, array $fileAttributes, string|null $lastVersion)

Initialize a task instance with the parameters
  • Abstract:

Overridden in child classes as:

PEAR_Task_Postinstallscript::init()
Initialize a task instance with the parameters
PEAR_Task_Windowseol::init()
Initialize a task instance with the parameters
PEAR_Task_Replace::init()
Initialize a task instance with the parameters
PEAR_Task_Unixeol::init()
Initialize a task instance with the parameters

Parameters:

array   $xml     raw, parsed xml
array   $fileAttributes     attributes from the <file> tag containing this task
string|null   $lastVersion     last installed version of this package

[ Top ]

isScript   [line 191]

bool isScript( )

Determines whether a role is a script

[ Top ]

run   [line 158]

void run( array $tasks)

This method is used to process each of the tasks for a particular multiple class type. Simple tasks need not implement this method.
  • Abstract:
  • Access: protected

Overridden in child classes as:

PEAR_Task_Postinstallscript::run()
No longer used

Parameters:

array   $tasks     an array of tasks

[ Top ]

runPostinstallTasks   [line 175]

void runPostinstallTasks( )

  • Final:

[ Top ]

startSession   [line 146]

string|false|PEAR_Error startSession( PEAR_PackageFile_v2 $pkg, string $contents, string $dest)

Begin a task processing session. All multiple tasks will be processed after each file has been successfully installed, all simple tasks should perform their task here and return any errors using the custom throwError() method to allow forward compatibility

This method MUST NOT write out any changes to disk

  • Return: false to skip this file, PEAR_Error to fail (use $this->throwError), otherwise return the new contents
  • Abstract:

Overridden in child classes as:

PEAR_Task_Postinstallscript::startSession()
Unlike other tasks, the installed file name is passed in instead of the file contents,
PEAR_Task_Windowseol::startSession()
Replace all line endings with windows line endings
PEAR_Task_Replace::startSession()
Do a package.xml 1.0 replacement, with additional package-info fields available
PEAR_Task_Unixeol::startSession()
Replace all line endings with line endings customized for the current OS

Parameters:

PEAR_PackageFile_v2   $pkg     
string   $contents     file contents
string   $dest     the eventual final file location (informational only)

[ Top ]

throwError   [line 196]

void throwError( $msg, [ $code = -1])


Parameters:

   $msg     
   $code     

[ Top ]

validateXml   [line 118]

true|array validateXml( PEAR_PackageFile_v2 $pkg, array $xml, PEAR_Config $config, array $fileXml)

Validate the basic contents of a task tag.
  • Return:

    On error, return an array in format: array(PEAR_TASK_ERROR_???[, param1][, param2][, ...])

    For PEAR_TASK_ERROR_MISSING_ATTRIB, pass the attribute name in For PEAR_TASK_ERROR_WRONG_ATTRIB_VALUE, pass the attribute name and an array of legal values in

  • Abstract:

Overridden in child classes as:

PEAR_Task_Postinstallscript::validateXml()
Validate the raw xml at parsing-time.
PEAR_Task_Windowseol::validateXml()
Validate the raw xml at parsing-time.
PEAR_Task_Replace::validateXml()
Validate the raw xml at parsing-time.
PEAR_Task_Unixeol::validateXml()
Validate the raw xml at parsing-time.

Parameters:

PEAR_PackageFile_v2   $pkg     
array   $xml     
PEAR_Config   $config     
array   $fileXml     the entire parsed <file> tag

[ Top ]


Documentation generated on Wed, 06 Jul 2011 23:30:35 +0000 by phpDocumentor 1.4.3. PEAR Logo Copyright © PHP Group 2004.