Text helper library.
Text manipulations: Highlight, excerpt, truncate, strip of links, convert email addresses to mailto: links...
Cake\Utility\Text
$_defaultConfig
protected array
$_engine
protected stdClass
$_placeholders
protected array
An array of md5sums and their contents. Used when inserting links into text.
$helpers
public array
$Html
public Saves the placeholder for a string, for later use. This gets around double escaping content in URL's.
Adds links (<a href=....) to a given text, by finding text that begins with strings like http:// and ftp://.
Formats paragraphs around given text for all line breaks
added for single line return
<
p> added for double line return
Extracts an excerpt from the text surrounding the phrase with a number of characters on each side determined by radius.
Highlights a given phrase in a text. You can specify any expression in highlighter that may include the \1 expression to include the $phrase found.
__call( string $method , array $params )
Call methods from String utility class
$method
$params
Cake\View\Helper::__call()
__construct( Cake\View\View $View , array $config [] )
Constructor
engine
Class name to use to replace String functionality. The class needs to be placed in the Utility
directory.Cake\View\View
$View
$config
optional [] Cake\Core\Exception\Exception
Cake\View\Helper::__construct()
_insertPlaceHolder( array $matches )
Saves the placeholder for a string, for later use. This gets around double escaping content in URL's.
$matches
_linkEmails( string $text , array $options )
Links email addresses
$text
$options
_linkUrls( string $text , array $htmlOptions )
Replace placeholders with links.
$text
$htmlOptions
autoLink( string $text , array $options [] )
Convert all links and email addresses to HTML links.
escape
Control HTML escaping of input. Defaults to true.$text
$options
optional [] autoLinkEmails( string $text , array $options [] )
Adds email links (<a href="mailto:....) to a given text.
escape
Control HTML escaping of input. Defaults to true.$text
$options
optional [] autoLinkUrls( string $text , array $options [] )
Adds links (<a href=....) to a given text, by finding text that begins with strings like http:// and ftp://.
escape
Control HTML escaping of input. Defaults to true.$text
$options
optional [] autoParagraph( string $text )
Formats paragraphs around given text for all line breaks
added for single line return
<
p> added for double line return
$text
The text with proper
<
p> and
tags
excerpt( string $text , string $phrase , integer $radius 100 , string $ending '...' )
Extracts an excerpt from the text surrounding the phrase with a number of characters on each side determined by radius.
$text
$phrase
$radius
optional 100 $ending
optional '...' highlight( string $text , string $phrase , array $options [] )
Highlights a given phrase in a text. You can specify any expression in highlighter that may include the \1 expression to include the $phrase found.
$text
$phrase
$options
optional [] implementedEvents( )
Event listeners.
Cake\View\Helper::implementedEvents()
stripLinks( string $text )
Strips given text of all links (<a href=....)
$text
tail( string $text , integer $length 100 , array $options [] )
Truncates text starting from the end.
Cuts a string to the length of $length and replaces the first characters with the ellipsis if the text is longer than length.
ellipsis
Will be used as Beginning and prepended to the trimmed stringexact
If false, $text will not be cut mid-word$text
$length
optional 100 $options
optional [] toList( array $list , string|null $and null , string $separator ', ' )
Creates a comma separated list where the last two items are joined with 'and', forming natural language.
$list
$and
optional null $separator
optional ', ' truncate( string $text , integer $length 100 , array $options [] )
Truncates text.
Cuts a string to the length of $length and replaces the last characters with the ellipsis if the text is longer than length.
ellipsis
Will be used as Ending and appended to the trimmed stringexact
If false, $text will not be cut mid-wordhtml
If true, HTML tags would be handled correctly$text
$length
optional 100 $options
optional [] __debugInfo( )
Returns an array that can be used to describe the internal state of this object.
__get( string $name )
Lazy loads helpers.
$name
Cake\View\Helper
|null_confirm( string $message , string $okCode , string $cancelCode '' , array $options [] )
Returns a string to be used as onclick handler for confirm dialogs.
$message
$okCode
$cancelCode
optional '' $options
optional [] addClass( array $options [] , string|null $class null , string $key 'class' )
Adds the given class to the element options
$options
optional [] $class
optional null $key
optional 'class' getView( )
Get the view instance this helper is bound to.
Cake\View\View
initialize( array $config )
Constructor hook method.
Implement this method to avoid having to overwrite the constructor and call parent.
$config
_configDelete( string $key )
Deletes a single config key.
$key
Cake\Core\Exception\Exception
_configRead( string|null $key )
Reads a config key.
$key
_configWrite( string|array $key , mixed $value , boolean|string $merge false )
Writes a config key.
$key
$value
$merge
optional false True to merge recursively, 'shallow' for simple merge, false to overwrite, defaults to false.
Cake\Core\Exception\Exception
config( string|array|null $key null , mixed|null $value null , boolean $merge true )
Gets/Sets the config.
Reading the whole config:
$this->config();
Reading a specific value:
$this->config('key');
Reading a nested value:
$this->config('some.nested.key');
Setting a specific value:
$this->config('key', $value);
Setting a nested value:
$this->config('some.nested.key', $value);
Updating multiple config settings at the same time:
$this->config(['one' => 'value', 'another' => 'value']);
$key
optional null $value
optional null $merge
optional true Cake\Core\Exception\Exception
configShallow( string|array $key , mixed|null $value null )
Merge provided config with existing config. Unlike config()
which does a recursive merge for nested keys, this method does a simple merge.
Setting a specific value:
$this->config('key', $value);
Setting a nested value:
$this->config('some.nested.key', $value);
Updating multiple config settings at the same time:
$this->config(['one' => 'value', 'another' => 'value']);
$key
$value
optional null getConfig( string|null $key null )
Returns the config.
Reading the whole config:
$this->getConfig();
Reading a specific value:
$this->getConfig('key');
Reading a nested value:
$this->getConfig('some.nested.key');
$key
optional null setConfig( string|array $key , mixed|null $value null , boolean $merge true )
Sets the config.
Setting a specific value:
$this->setConfig('key', $value);
Setting a nested value:
$this->setConfig('some.nested.key', $value);
Updating multiple config settings at the same time:
$this->setConfig(['one' => 'value', 'another' => 'value']);
$key
$value
optional null $merge
optional true Cake\Core\Exception\Exception
protected array
Default config for this class
[ 'engine' => 'Cake\Utility\Text' ]
protected array
An array of md5sums and their contents. Used when inserting links into text.
[]
public Cake\View\Helper\HtmlHelper
© 2005–2017 The Cake Software Foundation, Inc.
Licensed under the MIT License.
CakePHP is a registered trademark of Cake Software Foundation, Inc.
We are not endorsed by or affiliated with CakePHP.
https://api.cakephp.org/3.4/class-Cake.View.Helper.TextHelper.html