classes/phing/filters/ReplaceTokens.php

\ReplaceTokens

Replaces tokens in the original input with user-supplied values.

Example:

;
  

Or:


  
  
  
Extends from
\BaseParamFilterReader
Implements
\ChainableReader
see
\BaseParamFilterReader
access
public
author
Yannick Lecaillez
author
hans lellelid, hans@velum.net
copyright
© 2003 seasonfive. All rights reserved
package
phing.filters
version
$Revision: 1039 $ $Date: 2011-02-20 20:19:21 +0100 (Sun, 20 Feb 2011) $

Constants

Constantstring  DEFAULT_BEGIN_TOKEN = '@'

Default "begin token" character.

string
Constantstring  DEFAULT_END_TOKEN = '@'

Default "end token" character.

string

Properties

Propertyprivatearray  $_alltokens= 'null'

Array holding all tokens given directly to the Filter and those passed via a TokenSource.

Default valuenullDetails
Type
array
Propertyprivatestring  $_beginToken= '@'

Character marking the beginning of a token.

Default value@Details
Type
string
Propertyprivatestring  $_endToken= '@'

Character marking the end of a token.

Default value@Details
Type
string
Propertyprivatestring  $_queuedData= 'null'

[Deprecated] Data that must be read from, if not null.

Default valuenullDetails
Type
string
Propertyprivatearray  $_tokens= 'array'

Array to hold the replacee-replacer pairs (String to String).

Default valuearrayDetails
Type
array
Propertyprivatearray  $_tokensources= 'array'

Array to hold the token sources that make tokens from different sources available

Default valuearrayDetails
Type
array

Methods

methodprivate  _initialize( ) :
Initializes tokens and loads the replacee-replacer hashtable.

This method is only called when this filter is used through a tag in build file.

methodpublic  chain( object $reader ) : object
Creates a new ReplaceTokens using the passed in Reader for instantiation.
Parameters
Name Type Description
$reader object

A Reader object providing the underlying stream. Must not be null.

Returns
Type Description
object
methodpublic  createToken( ) : object
Adds a token element to the map of tokens to replace.
Returns
Type Description
object
methodpublic  createTokensource( ) : object
Adds a token source to the sources of this filter.
Returns
Type Description
object
methodpublic  getBeginToken( ) : string
Returns the "begin token" character.
Returns
Type Description
string
methodpublic  getEndToken( ) : \the
Returns the "end token" character.
Returns
Type Description
\the
methodpublic  getTokens( ) : array
Returns the map of tokens which will be replaced.

; used by ReplaceTokens::chain()

Returns
Type Description
array
methodpublic  getTokensources( ) : array
Returns the token sources used by this filter; used by ReplaceTokens::chain()
Returns
Type Description
array
methodpublic  read(  $len = null ) : mixed
Returns stream with tokens having been replaced with appropriate values.

If a replacement value is not found for a token, the token is left in the stream.

Parameters
Name Type Description
$len
Returns
Type Description
mixed
methodprivate  replaceTokenCallback( array $matches ) : string
Performs lookup on key and returns appropriate replacement string.
Parameters
Name Type Description
$matches array Array of 1 el containing key to search for.
Returns
Type Description
string
Details
access
private
methodpublic  setBeginToken( string $beginToken ) :
Sets the "begin token" character.
Parameters
Name Type Description
$beginToken string the character used to denote the beginning of a token.
methodpublic  setEndToken( string $endToken ) :
Sets the "end token" character.
Parameters
Name Type Description
$endToken string the character used to denote the end of a token
methodpublic  setTokens( array $tokens ) :
Sets the map of tokens to replace.

; used by ReplaceTokens::chain()

Parameters
Name Type Description
$tokens array

A map (String->String) of token keys to replacement values. Must not be null.

methodpublic  setTokensources( array $sources ) :
Sets the tokensources to use; used by ReplaceTokens::chain()
Parameters
Name Type Description
$sources array An array of token sources.

\Token

Holds a token.

package
phing.filters

Properties

Propertyprivatestring  $_key= ''

Token key.

Details
Type
string
Propertyprivatestring  $_value= ''

Token value.

Details
Type
string

Methods

methodpublic  addText( string $value ) :
Sets the token value from text.
Parameters
Name Type Description
$value string

The value for this token. Must not be null.

methodpublic  getKey( ) : string
Returns the key for this token.
Returns
Type Description
string
methodpublic  getValue( ) : string
Returns the value for this token.
Returns
Type Description
string
methodpublic  setKey( string $key ) :
Sets the token key.
Parameters
Name Type Description
$key string

The key for this token. Must not be null.

methodpublic  setValue( string $value ) :
Sets the token value.
Parameters
Name Type Description
$value string

The value for this token. Must not be null.

Documentation was generated by DocBlox 0.13.1.