App::uses and usage replacements for String => CakeText.

This commit is contained in:
euromark 2015-01-05 01:00:57 +01:00
parent 63093e1d30
commit 52ecccb1a2
18 changed files with 51 additions and 51 deletions

View file

@ -122,7 +122,7 @@ class SchemaShell extends AppShell {
if ($this->params['force']) { if ($this->params['force']) {
$options['models'] = false; $options['models'] = false;
} elseif (!empty($this->params['models'])) { } elseif (!empty($this->params['models'])) {
$options['models'] = String::tokenize($this->params['models']); $options['models'] = CakeText::tokenize($this->params['models']);
} }
$snapshot = false; $snapshot = false;
@ -151,7 +151,7 @@ class SchemaShell extends AppShell {
Configure::write('Cache.disable', $cacheDisable); Configure::write('Cache.disable', $cacheDisable);
if (!empty($this->params['exclude']) && !empty($content)) { if (!empty($this->params['exclude']) && !empty($content)) {
$excluded = String::tokenize($this->params['exclude']); $excluded = CakeText::tokenize($this->params['exclude']);
foreach ($excluded as $table) { foreach ($excluded as $table) {
unset($content['tables'][$table]); unset($content['tables'][$table]);
} }

View file

@ -340,7 +340,7 @@ class FixtureTask extends BakeTask {
isset($fieldInfo['length']) && $fieldInfo['length'] == 36 isset($fieldInfo['length']) && $fieldInfo['length'] == 36
); );
if ($isPrimaryUuid) { if ($isPrimaryUuid) {
$insert = String::uuid(); $insert = CakeText::uuid();
} else { } else {
$insert = "Lorem ipsum dolor sit amet"; $insert = "Lorem ipsum dolor sit amet";
if (!empty($fieldInfo['length'])) { if (!empty($fieldInfo['length'])) {

View file

@ -18,7 +18,7 @@
App::uses('AppShell', 'Console/Command'); App::uses('AppShell', 'Console/Command');
App::uses('File', 'Utility'); App::uses('File', 'Utility');
App::uses('Folder', 'Utility'); App::uses('Folder', 'Utility');
App::uses('String', 'Utility'); App::uses('CakeText', 'Utility');
App::uses('Security', 'Utility'); App::uses('Security', 'Utility');
/** /**
@ -212,7 +212,7 @@ class ProjectTask extends AppShell {
} }
foreach ($Folder->messages() as $message) { foreach ($Folder->messages() as $message) {
$this->out(String::wrap(' * ' . $message), 1, Shell::VERBOSE); $this->out(CakeText::wrap(' * ' . $message), 1, Shell::VERBOSE);
} }
return true; return true;

View file

@ -14,7 +14,7 @@
* @license http://www.opensource.org/licenses/mit-license.php MIT License * @license http://www.opensource.org/licenses/mit-license.php MIT License
*/ */
App::uses('String', 'Utility'); App::uses('CakeText', 'Utility');
/** /**
* HelpFormatter formats help for console shells. Can format to either * HelpFormatter formats help for console shells. Can format to either
@ -64,7 +64,7 @@ class HelpFormatter {
$out = array(); $out = array();
$description = $parser->description(); $description = $parser->description();
if (!empty($description)) { if (!empty($description)) {
$out[] = String::wrap($description, $width); $out[] = CakeText::wrap($description, $width);
$out[] = ''; $out[] = '';
} }
$out[] = __d('cake_console', '<info>Usage:</info>'); $out[] = __d('cake_console', '<info>Usage:</info>');
@ -76,7 +76,7 @@ class HelpFormatter {
$out[] = ''; $out[] = '';
$max = $this->_getMaxLength($subcommands) + 2; $max = $this->_getMaxLength($subcommands) + 2;
foreach ($subcommands as $command) { foreach ($subcommands as $command) {
$out[] = String::wrap($command->help($max), array( $out[] = CakeText::wrap($command->help($max), array(
'width' => $width, 'width' => $width,
'indent' => str_repeat(' ', $max), 'indent' => str_repeat(' ', $max),
'indentAt' => 1 'indentAt' => 1
@ -93,7 +93,7 @@ class HelpFormatter {
$out[] = __d('cake_console', '<info>Options:</info>'); $out[] = __d('cake_console', '<info>Options:</info>');
$out[] = ''; $out[] = '';
foreach ($options as $option) { foreach ($options as $option) {
$out[] = String::wrap($option->help($max), array( $out[] = CakeText::wrap($option->help($max), array(
'width' => $width, 'width' => $width,
'indent' => str_repeat(' ', $max), 'indent' => str_repeat(' ', $max),
'indentAt' => 1 'indentAt' => 1
@ -108,7 +108,7 @@ class HelpFormatter {
$out[] = __d('cake_console', '<info>Arguments:</info>'); $out[] = __d('cake_console', '<info>Arguments:</info>');
$out[] = ''; $out[] = '';
foreach ($arguments as $argument) { foreach ($arguments as $argument) {
$out[] = String::wrap($argument->help($max), array( $out[] = CakeText::wrap($argument->help($max), array(
'width' => $width, 'width' => $width,
'indent' => str_repeat(' ', $max), 'indent' => str_repeat(' ', $max),
'indentAt' => 1 'indentAt' => 1
@ -118,7 +118,7 @@ class HelpFormatter {
} }
$epilog = $parser->epilog(); $epilog = $parser->epilog();
if (!empty($epilog)) { if (!empty($epilog)) {
$out[] = String::wrap($epilog, $width); $out[] = CakeText::wrap($epilog, $width);
$out[] = ''; $out[] = '';
} }
return implode("\n", $out); return implode("\n", $out);

View file

@ -584,11 +584,11 @@ class Shell extends Object {
* @param string $text Text the text to format. * @param string $text Text the text to format.
* @param string|int|array $options Array of options to use, or an integer to wrap the text to. * @param string|int|array $options Array of options to use, or an integer to wrap the text to.
* @return string Wrapped / indented text * @return string Wrapped / indented text
* @see String::wrap() * @see CakeText::wrap()
* @link http://book.cakephp.org/2.0/en/console-and-shells.html#Shell::wrapText * @link http://book.cakephp.org/2.0/en/console-and-shells.html#Shell::wrapText
*/ */
public function wrapText($text, $options = array()) { public function wrapText($text, $options = array()) {
return String::wrap($text, $options); return CakeText::wrap($text, $options);
} }
/** /**

View file

@ -17,7 +17,7 @@
*/ */
App::uses('Component', 'Controller'); App::uses('Component', 'Controller');
App::uses('String', 'Utility'); App::uses('CakeText', 'Utility');
App::uses('Hash', 'Utility'); App::uses('Hash', 'Utility');
App::uses('Security', 'Utility'); App::uses('Security', 'Utility');

View file

@ -103,10 +103,10 @@ class Configure {
self::$_values['Exception'] self::$_values['Exception']
); );
// Preload Debugger + String in case of E_STRICT errors when loading files. // Preload Debugger + CakeText in case of E_STRICT errors when loading files.
if (self::$_values['debug'] > 0) { if (self::$_values['debug'] > 0) {
class_exists('Debugger'); class_exists('Debugger');
class_exists('String'); class_exists('CakeText');
} }
} }
} }

View file

@ -140,7 +140,7 @@ class TranslateBehavior extends ModelBehavior {
unset($this->_joinTable, $this->_runtimeModel); unset($this->_joinTable, $this->_runtimeModel);
return $query; return $query;
} elseif (is_string($query['fields'])) { } elseif (is_string($query['fields'])) {
$query['fields'] = String::tokenize($query['fields']); $query['fields'] = CakeText::tokenize($query['fields']);
} }
$fields = array_merge( $fields = array_merge(

View file

@ -17,7 +17,7 @@
*/ */
App::uses('DboSource', 'Model/Datasource'); App::uses('DboSource', 'Model/Datasource');
App::uses('String', 'Utility'); App::uses('CakeText', 'Utility');
/** /**
* DBO implementation for the SQLite3 DBMS. * DBO implementation for the SQLite3 DBMS.
@ -303,7 +303,7 @@ class Sqlite extends DboSource {
if (stripos($querystring, 'SELECT') === 0 && stripos($querystring, 'FROM') > 0) { if (stripos($querystring, 'SELECT') === 0 && stripos($querystring, 'FROM') > 0) {
$selectpart = substr($querystring, 7); $selectpart = substr($querystring, 7);
$selects = array(); $selects = array();
foreach (String::tokenize($selectpart, ',', '(', ')') as $part) { foreach (CakeText::tokenize($selectpart, ',', '(', ')') as $part) {
$fromPos = stripos($part, ' FROM '); $fromPos = stripos($part, ' FROM ');
if ($fromPos !== false) { if ($fromPos !== false) {
$selects[] = trim(substr($part, 0, $fromPos)); $selects[] = trim(substr($part, 0, $fromPos));

View file

@ -17,7 +17,7 @@
*/ */
App::uses('DataSource', 'Model/Datasource'); App::uses('DataSource', 'Model/Datasource');
App::uses('String', 'Utility'); App::uses('CakeText', 'Utility');
App::uses('View', 'View'); App::uses('View', 'View');
/** /**
@ -2513,7 +2513,7 @@ class DboSource extends DataSource {
if ($allFields) { if ($allFields) {
$fields = array_keys($Model->schema()); $fields = array_keys($Model->schema());
} elseif (!is_array($fields)) { } elseif (!is_array($fields)) {
$fields = String::tokenize($fields); $fields = CakeText::tokenize($fields);
} }
$fields = array_values(array_filter($fields)); $fields = array_values(array_filter($fields));
$allFields = $allFields || in_array('*', $fields) || in_array($Model->alias . '.*', $fields); $allFields = $allFields || in_array('*', $fields) || in_array($Model->alias . '.*', $fields);
@ -2813,7 +2813,7 @@ class DboSource extends DataSource {
} }
if ($bound) { if ($bound) {
return String::insert($key . ' ' . trim($operator), $value); return CakeText::insert($key . ' ' . trim($operator), $value);
} }
if (!preg_match($operatorMatch, trim($operator))) { if (!preg_match($operatorMatch, trim($operator))) {

View file

@ -20,7 +20,7 @@
App::uses('ClassRegistry', 'Utility'); App::uses('ClassRegistry', 'Utility');
App::uses('Validation', 'Utility'); App::uses('Validation', 'Utility');
App::uses('String', 'Utility'); App::uses('CakeText', 'Utility');
App::uses('Hash', 'Utility'); App::uses('Hash', 'Utility');
App::uses('BehaviorCollection', 'Model'); App::uses('BehaviorCollection', 'Model');
App::uses('ModelBehavior', 'Model'); App::uses('ModelBehavior', 'Model');
@ -1915,9 +1915,9 @@ class Model extends Object implements CakeEventListener {
if (empty($this->data[$this->alias][$this->primaryKey]) && $this->_isUUIDField($this->primaryKey)) { if (empty($this->data[$this->alias][$this->primaryKey]) && $this->_isUUIDField($this->primaryKey)) {
if (array_key_exists($this->primaryKey, $this->data[$this->alias])) { if (array_key_exists($this->primaryKey, $this->data[$this->alias])) {
$j = array_search($this->primaryKey, $fields); $j = array_search($this->primaryKey, $fields);
$values[$j] = String::uuid(); $values[$j] = CakeText::uuid();
} else { } else {
list($fields[], $values[]) = array($this->primaryKey, String::uuid()); list($fields[], $values[]) = array($this->primaryKey, CakeText::uuid());
} }
} }
@ -2026,7 +2026,7 @@ class Model extends Object implements CakeEventListener {
$values = array($id, $row); $values = array($id, $row);
if ($isUUID && $primaryAdded) { if ($isUUID && $primaryAdded) {
$values[] = String::uuid(); $values[] = CakeText::uuid();
} }
$newValues[$row] = $values; $newValues[$row] = $values;
@ -3187,7 +3187,7 @@ class Model extends Object implements CakeEventListener {
$list = array("{n}.{$this->alias}.{$this->primaryKey}", "{n}.{$this->alias}.{$this->displayField}", null); $list = array("{n}.{$this->alias}.{$this->primaryKey}", "{n}.{$this->alias}.{$this->displayField}", null);
} else { } else {
if (!is_array($query['fields'])) { if (!is_array($query['fields'])) {
$query['fields'] = String::tokenize($query['fields']); $query['fields'] = CakeText::tokenize($query['fields']);
} }
if (count($query['fields']) === 1) { if (count($query['fields']) === 1) {

View file

@ -17,7 +17,7 @@
App::uses('Multibyte', 'I18n'); App::uses('Multibyte', 'I18n');
App::uses('AbstractTransport', 'Network/Email'); App::uses('AbstractTransport', 'Network/Email');
App::uses('File', 'Utility'); App::uses('File', 'Utility');
App::uses('String', 'Utility'); App::uses('CakeText', 'Utility');
App::uses('View', 'View'); App::uses('View', 'View');
/** /**
@ -776,7 +776,7 @@ class CakeEmail {
} }
if ($this->_messageId !== false) { if ($this->_messageId !== false) {
if ($this->_messageId === true) { if ($this->_messageId === true) {
$headers['Message-ID'] = '<' . str_replace('-', '', String::UUID()) . '@' . $this->_domain . '>'; $headers['Message-ID'] = '<' . str_replace('-', '', CakeText::UUID()) . '@' . $this->_domain . '>';
} else { } else {
$headers['Message-ID'] = $this->_messageId; $headers['Message-ID'] = $this->_messageId;
} }

View file

@ -20,7 +20,7 @@
App::uses('Model', 'Model'); App::uses('Model', 'Model');
App::uses('AppModel', 'Model'); App::uses('AppModel', 'Model');
App::uses('String', 'Utility'); App::uses('CakeText', 'Utility');
require_once dirname(dirname(__FILE__)) . DS . 'models.php'; require_once dirname(dirname(__FILE__)) . DS . 'models.php';
@ -73,7 +73,7 @@ class TreeBehaviorUuidTest extends CakeTestCase {
'conditions' => array($modelClass . '.name' => '1.1') 'conditions' => array($modelClass . '.name' => '1.1')
)); ));
$id = String::uuid(); $id = CakeText::uuid();
$this->Tree->create(); $this->Tree->create();
$result = $this->Tree->save(array($modelClass => array( $result = $this->Tree->save(array($modelClass => array(
'id' => $id, 'id' => $id,

View file

@ -19,7 +19,7 @@
*/ */
App::uses('CakeLog', 'Log'); App::uses('CakeLog', 'Log');
App::uses('String', 'Utility'); App::uses('CakeText', 'Utility');
/** /**
* Provide custom logging and error handling. * Provide custom logging and error handling.
@ -337,7 +337,7 @@ class Debugger {
$trace['path'] = self::trimPath($trace['file']); $trace['path'] = self::trimPath($trace['file']);
$trace['reference'] = $reference; $trace['reference'] = $reference;
unset($trace['object'], $trace['args']); unset($trace['object'], $trace['args']);
$back[] = String::insert($tpl, $trace, array('before' => '{:', 'after' => '}')); $back[] = CakeText::insert($tpl, $trace, array('before' => '{:', 'after' => '}'));
} }
} }
@ -637,7 +637,7 @@ class Debugger {
* *
* `Debugger::addFormat('custom', $data);` * `Debugger::addFormat('custom', $data);`
* *
* Where $data is an array of strings that use String::insert() variable * Where $data is an array of strings that use CakeText::insert() variable
* replacement. The template vars should be in a `{:id}` style. * replacement. The template vars should be in a `{:id}` style.
* An error formatter can have the following keys: * An error formatter can have the following keys:
* *
@ -775,7 +775,7 @@ class Debugger {
if (isset($tpl['links'])) { if (isset($tpl['links'])) {
foreach ($tpl['links'] as $key => $val) { foreach ($tpl['links'] as $key => $val) {
$links[$key] = String::insert($val, $data, $insertOpts); $links[$key] = CakeText::insert($val, $data, $insertOpts);
} }
} }
@ -791,14 +791,14 @@ class Debugger {
if (is_array($value)) { if (is_array($value)) {
$value = implode("\n", $value); $value = implode("\n", $value);
} }
$info .= String::insert($tpl[$key], array($key => $value) + $data, $insertOpts); $info .= CakeText::insert($tpl[$key], array($key => $value) + $data, $insertOpts);
} }
$links = implode(' ', $links); $links = implode(' ', $links);
if (isset($tpl['callback']) && is_callable($tpl['callback'])) { if (isset($tpl['callback']) && is_callable($tpl['callback'])) {
return call_user_func($tpl['callback'], $data, compact('links', 'info')); return call_user_func($tpl['callback'], $data, compact('links', 'info'));
} }
echo String::insert($tpl['error'], compact('links', 'info') + $data, $insertOpts); echo CakeText::insert($tpl['error'], compact('links', 'info') + $data, $insertOpts);
} }
/** /**

View file

@ -14,7 +14,7 @@
* @license http://www.opensource.org/licenses/mit-license.php MIT License * @license http://www.opensource.org/licenses/mit-license.php MIT License
*/ */
App::uses('String', 'Utility'); App::uses('CakeText', 'Utility');
/** /**
* Library of array functions for manipulating and extracting data * Library of array functions for manipulating and extracting data
@ -112,7 +112,7 @@ class Hash {
if (strpos($path, '[') === false) { if (strpos($path, '[') === false) {
$tokens = explode('.', $path); $tokens = explode('.', $path);
} else { } else {
$tokens = String::tokenize($path, '.', '[', ']'); $tokens = CakeText::tokenize($path, '.', '[', ']');
} }
$_key = '__set_item__'; $_key = '__set_item__';
@ -258,7 +258,7 @@ class Hash {
if (strpos($path, '[') === false) { if (strpos($path, '[') === false) {
$tokens = explode('.', $path); $tokens = explode('.', $path);
} else { } else {
$tokens = String::tokenize($path, '.', '[', ']'); $tokens = CakeText::tokenize($path, '.', '[', ']');
} }
if (strpos($path, '{') === false && strpos($path, '[') === false) { if (strpos($path, '{') === false && strpos($path, '[') === false) {
@ -341,7 +341,7 @@ class Hash {
if (strpos($path, '[') === false) { if (strpos($path, '[') === false) {
$tokens = explode('.', $path); $tokens = explode('.', $path);
} else { } else {
$tokens = String::tokenize($path, '.', '[', ']'); $tokens = CakeText::tokenize($path, '.', '[', ']');
} }
if (strpos($path, '{') === false && strpos($path, '[') === false) { if (strpos($path, '{') === false && strpos($path, '[') === false) {

View file

@ -16,7 +16,7 @@
* @license http://www.opensource.org/licenses/mit-license.php MIT License * @license http://www.opensource.org/licenses/mit-license.php MIT License
*/ */
App::uses('String', 'Utility'); App::uses('CakeText', 'Utility');
/** /**
* Security Library contains utility methods related to security * Security Library contains utility methods related to security
@ -63,7 +63,7 @@ class Security {
* @return string Hash * @return string Hash
*/ */
public static function generateAuthKey() { public static function generateAuthKey() {
return Security::hash(String::uuid()); return Security::hash(CakeText::uuid());
} }
/** /**

View file

@ -16,7 +16,7 @@
* @license http://www.opensource.org/licenses/mit-license.php MIT License * @license http://www.opensource.org/licenses/mit-license.php MIT License
*/ */
App::uses('String', 'Utility'); App::uses('CakeText', 'Utility');
App::uses('Hash', 'Utility'); App::uses('Hash', 'Utility');
/** /**
@ -549,7 +549,7 @@ class Set {
return null; return null;
} }
if (is_string($path) && strpos($path, '{') !== false) { if (is_string($path) && strpos($path, '{') !== false) {
$path = String::tokenize($path, '.', '{', '}'); $path = CakeText::tokenize($path, '.', '{', '}');
} elseif (is_string($path)) { } elseif (is_string($path)) {
$path = explode('.', $path); $path = explode('.', $path);
} }

View file

@ -225,7 +225,7 @@ class TextHelper extends AppHelper {
* @param string $phrase The phrase that will be searched * @param string $phrase The phrase that will be searched
* @param array $options An array of html attributes and options. * @param array $options An array of html attributes and options.
* @return string The highlighted text * @return string The highlighted text
* @see String::highlight() * @see CakeText::highlight()
* @link http://book.cakephp.org/2.0/en/core-libraries/helpers/text.html#TextHelper::highlight * @link http://book.cakephp.org/2.0/en/core-libraries/helpers/text.html#TextHelper::highlight
*/ */
public function highlight($text, $phrase, $options = array()) { public function highlight($text, $phrase, $options = array()) {
@ -260,7 +260,7 @@ class TextHelper extends AppHelper {
* *
* @param string $text Text * @param string $text Text
* @return string The text without links * @return string The text without links
* @see String::stripLinks() * @see CakeText::stripLinks()
* @link http://book.cakephp.org/2.0/en/core-libraries/helpers/text.html#TextHelper::stripLinks * @link http://book.cakephp.org/2.0/en/core-libraries/helpers/text.html#TextHelper::stripLinks
*/ */
public function stripLinks($text) { public function stripLinks($text) {
@ -283,7 +283,7 @@ class TextHelper extends AppHelper {
* @param int $length Length of returned string, including ellipsis. * @param int $length Length of returned string, including ellipsis.
* @param array $options An array of html attributes and options. * @param array $options An array of html attributes and options.
* @return string Trimmed string. * @return string Trimmed string.
* @see String::truncate() * @see CakeText::truncate()
* @link http://book.cakephp.org/2.0/en/core-libraries/helpers/text.html#TextHelper::truncate * @link http://book.cakephp.org/2.0/en/core-libraries/helpers/text.html#TextHelper::truncate
*/ */
public function truncate($text, $length = 100, $options = array()) { public function truncate($text, $length = 100, $options = array()) {
@ -305,7 +305,7 @@ class TextHelper extends AppHelper {
* @param int $length Length of returned string, including ellipsis. * @param int $length Length of returned string, including ellipsis.
* @param array $options An array of html attributes and options. * @param array $options An array of html attributes and options.
* @return string Trimmed string. * @return string Trimmed string.
* @see String::tail() * @see CakeText::tail()
* @link http://book.cakephp.org/2.0/en/core-libraries/helpers/text.html#TextHelper::tail * @link http://book.cakephp.org/2.0/en/core-libraries/helpers/text.html#TextHelper::tail
*/ */
public function tail($text, $length = 100, $options = array()) { public function tail($text, $length = 100, $options = array()) {
@ -321,7 +321,7 @@ class TextHelper extends AppHelper {
* @param int $radius The amount of characters that will be returned on each side of the founded phrase * @param int $radius The amount of characters that will be returned on each side of the founded phrase
* @param string $ending Ending that will be appended * @param string $ending Ending that will be appended
* @return string Modified string * @return string Modified string
* @see String::excerpt() * @see CakeText::excerpt()
* @link http://book.cakephp.org/2.0/en/core-libraries/helpers/text.html#TextHelper::excerpt * @link http://book.cakephp.org/2.0/en/core-libraries/helpers/text.html#TextHelper::excerpt
*/ */
public function excerpt($text, $phrase, $radius = 100, $ending = '...') { public function excerpt($text, $phrase, $radius = 100, $ending = '...') {
@ -335,7 +335,7 @@ class TextHelper extends AppHelper {
* @param string $and The word used to join the last and second last items together with. Defaults to 'and'. * @param string $and The word used to join the last and second last items together with. Defaults to 'and'.
* @param string $separator The separator used to join all the other items together. Defaults to ', '. * @param string $separator The separator used to join all the other items together. Defaults to ', '.
* @return string The glued together string. * @return string The glued together string.
* @see String::toList() * @see CakeText::toList()
* @link http://book.cakephp.org/2.0/en/core-libraries/helpers/text.html#TextHelper::toList * @link http://book.cakephp.org/2.0/en/core-libraries/helpers/text.html#TextHelper::toList
*/ */
public function toList($list, $and = null, $separator = ', ') { public function toList($list, $and = null, $separator = ', ') {