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

Class: PEAR_Task_Common

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

Class Overview


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


Author(s):

Version:

  • Release: 1.10.12

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 76]

  • Access: protected

Type:   mixed


[ Top ]

$installphase =

[line 88]

  • Access: protected

Type:   mixed


[ Top ]

$logger =

[line 84]

  • Access: public

Type:   mixed


[ Top ]

$phase =  PEAR_TASK_INSTALL

[line 72]

Determines which install phase this task is executed under
  • Access: public

Type:   mixed


[ Top ]

$registry =

[line 80]

  • Access: protected

Type:   mixed


[ Top ]

$type =  'simple'

[line 68]

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

__construct (Constructor)   [line 93]

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


Overridden in child classes as:

PEAR_Task_Postinstallscript_rw::__construct()
Enter description here...
PEAR_Task_Windowseol_rw::__construct()
PEAR_Task_Replace_rw::__construct()
PEAR_Task_Unixeol_rw::__construct()

Parameters:

PEAR_Config   &$config   — 
PEAR_Common   &$logger   — 
   $phase   — 

[ Top ]

hasPostinstallTasks   [line 170]

void hasPostinstallTasks( )

  • Final:
  • Access: public

[ Top ]

init   [line 133]

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

Initialize a task instance with the parameters
  • Abstract:
  • Access: public

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 196]

bool isScript( )

Determines whether a role is a script
  • Access: public

[ Top ]

run   [line 163]

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.
  • Access: public

Overridden in child classes as:

PEAR_Task_Postinstallscript::run()
No longer used

Parameters:

array   $tasks   —  an array of tasks

[ Top ]

runPostinstallTasks   [line 178]

void runPostinstallTasks( )

  • Final:
  • Access: public

[ Top ]

startSession   [line 152]

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:
  • Access: public

Overridden in child classes as:

PEAR_Task_Postinstallscript::startSession()
Unlike other tasks, the installed file name is passed in instead of the file contents, because this task is handled post-installation
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 201]

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

  • Access: public

Parameters:

   $msg   — 
   $code   — 

[ Top ]

validateXml   [line 121]

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:
  • Access: public

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 Sun, 19 Apr 2020 14:22:12 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.