Skip to content

Commit 844a3bc

Browse files
committed
fixes agriya#1 : String class has changed to CakeText class.
1 parent b67860c commit 844a3bc

File tree

18 files changed

+62
-62
lines changed

18 files changed

+62
-62
lines changed

core/lib/Cake/Console/Command/Task/FixtureTask.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,7 @@ protected function _generateRecords($tableInfo, $recordCount = 1) {
310310
isset($fieldInfo['length']) && $fieldInfo['length'] == 36
311311
);
312312
if ($isPrimaryUuid) {
313-
$insert = String::uuid();
313+
$insert = CakeText::uuid();
314314
} else {
315315
$insert = "Lorem ipsum dolor sit amet";
316316
if (!empty($fieldInfo['length'])) {

core/lib/Cake/Console/Command/Task/ProjectTask.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
App::uses('AppShell', 'Console/Command');
2121
App::uses('File', 'Utility');
2222
App::uses('Folder', 'Utility');
23-
App::uses('String', 'Utility');
23+
App::uses('CakeText', 'Utility');
2424
App::uses('Security', 'Utility');
2525

2626
/**
@@ -207,7 +207,7 @@ public function bake($path, $skel = null, $skip = array('empty')) {
207207
}
208208

209209
foreach ($Folder->messages() as $message) {
210-
$this->out(String::wrap(' * ' . $message), 1, Shell::VERBOSE);
210+
$this->out(CakeText::wrap(' * ' . $message), 1, Shell::VERBOSE);
211211
}
212212

213213
return true;

core/lib/Cake/Console/HelpFormatter.php

+6-6
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
* @link http://cakephp.org CakePHP(tm) Project
1515
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
1616
*/
17-
App::uses('String', 'Utility');
17+
App::uses('CakeText', 'Utility');
1818

1919
/**
2020
* HelpFormatter formats help for console shells. Can format to either
@@ -64,7 +64,7 @@ public function text($width = 72) {
6464
$out = array();
6565
$description = $parser->description();
6666
if (!empty($description)) {
67-
$out[] = String::wrap($description, $width);
67+
$out[] = CakeText::wrap($description, $width);
6868
$out[] = '';
6969
}
7070
$out[] = __d('cake_console', '<info>Usage:</info>');
@@ -76,7 +76,7 @@ public function text($width = 72) {
7676
$out[] = '';
7777
$max = $this->_getMaxLength($subcommands) + 2;
7878
foreach ($subcommands as $command) {
79-
$out[] = String::wrap($command->help($max), array(
79+
$out[] = CakeText::wrap($command->help($max), array(
8080
'width' => $width,
8181
'indent' => str_repeat(' ', $max),
8282
'indentAt' => 1
@@ -93,7 +93,7 @@ public function text($width = 72) {
9393
$out[] = __d('cake_console', '<info>Options:</info>');
9494
$out[] = '';
9595
foreach ($options as $option) {
96-
$out[] = String::wrap($option->help($max), array(
96+
$out[] = CakeText::wrap($option->help($max), array(
9797
'width' => $width,
9898
'indent' => str_repeat(' ', $max),
9999
'indentAt' => 1
@@ -108,7 +108,7 @@ public function text($width = 72) {
108108
$out[] = __d('cake_console', '<info>Arguments:</info>');
109109
$out[] = '';
110110
foreach ($arguments as $argument) {
111-
$out[] = String::wrap($argument->help($max), array(
111+
$out[] = CakeText::wrap($argument->help($max), array(
112112
'width' => $width,
113113
'indent' => str_repeat(' ', $max),
114114
'indentAt' => 1
@@ -118,7 +118,7 @@ public function text($width = 72) {
118118
}
119119
$epilog = $parser->epilog();
120120
if (!empty($epilog)) {
121-
$out[] = String::wrap($epilog, $width);
121+
$out[] = CakeText::wrap($epilog, $width);
122122
$out[] = '';
123123
}
124124
return implode("\n", $out);

core/lib/Cake/Console/Shell.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -534,11 +534,11 @@ protected function _getInput($prompt, $options, $default) {
534534
* @param string $text Text the text to format.
535535
* @param string|integer|array $options Array of options to use, or an integer to wrap the text to.
536536
* @return string Wrapped / indented text
537-
* @see String::wrap()
537+
* @see CakeText::wrap()
538538
* @link http://book.cakephp.org/2.0/en/console-and-shells.html#Shell::wrapText
539539
*/
540540
public function wrapText($text, $options = array()) {
541-
return String::wrap($text, $options);
541+
return CakeText::wrap($text, $options);
542542
}
543543

544544
/**

core/lib/Cake/Controller/Component/SecurityComponent.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
*/
1919

2020
App::uses('Component', 'Controller');
21-
App::uses('String', 'Utility');
21+
App::uses('CakeText', 'Utility');
2222
App::uses('Hash', 'Utility');
2323
App::uses('Security', 'Utility');
2424

core/lib/Cake/Error/ErrorHandler.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ class ErrorHandler {
107107
* @return void
108108
* @see http://php.net/manual/en/function.set-exception-handler.php
109109
*/
110-
public static function handleException(Exception $exception) {
110+
public static function handleException($exception) {
111111
$config = Configure::read('Exception');
112112
if (!empty($config['log'])) {
113113
$message = sprintf("[%s] %s\n%s",

core/lib/Cake/Error/ExceptionRenderer.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ class ExceptionRenderer {
8888
*
8989
* @param Exception $exception Exception
9090
*/
91-
public function __construct(Exception $exception) {
91+
public function __construct($exception) {
9292
$this->controller = $this->_getController($exception);
9393

9494
if (method_exists($this->controller, 'apperror')) {

core/lib/Cake/Model/Datasource/Database/Sqlite.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
*/
1919

2020
App::uses('DboSource', 'Model/Datasource');
21-
App::uses('String', 'Utility');
21+
App::uses('CakeText', 'Utility');
2222

2323
/**
2424
* DBO implementation for the SQLite3 DBMS.
@@ -283,7 +283,7 @@ public function resultSet($results) {
283283
$last = strripos($querystring, 'FROM');
284284
if ($last !== false) {
285285
$selectpart = substr($querystring, 7, $last - 8);
286-
$selects = String::tokenize($selectpart, ',', '(', ')');
286+
$selects = CakeText::tokenize($selectpart, ',', '(', ')');
287287
}
288288
} elseif (strpos($querystring, 'PRAGMA table_info') === 0) {
289289
$selects = array('cid', 'name', 'type', 'notnull', 'dflt_value', 'pk');

core/lib/Cake/Model/Datasource/DboSource.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
*/
1919

2020
App::uses('DataSource', 'Model/Datasource');
21-
App::uses('String', 'Utility');
21+
App::uses('CakeText', 'Utility');
2222
App::uses('View', 'View');
2323

2424
/**
@@ -2303,7 +2303,7 @@ public function fields(Model $model, $alias = null, $fields = array(), $quote =
23032303
if ($allFields) {
23042304
$fields = array_keys($model->schema());
23052305
} elseif (!is_array($fields)) {
2306-
$fields = String::tokenize($fields);
2306+
$fields = CakeText::tokenize($fields);
23072307
}
23082308
$fields = array_values(array_filter($fields));
23092309
$allFields = $allFields || in_array('*', $fields) || in_array($model->alias . '.*', $fields);
@@ -2589,7 +2589,7 @@ protected function _parseKey($model, $key, $value) {
25892589
}
25902590

25912591
if ($bound) {
2592-
return String::insert($key . ' ' . trim($operator), $value);
2592+
return CakeText::insert($key . ' ' . trim($operator), $value);
25932593
}
25942594

25952595
if (!preg_match($operatorMatch, trim($operator))) {

core/lib/Cake/Model/Model.php

+5-5
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121

2222
App::uses('ClassRegistry', 'Utility');
2323
App::uses('Validation', 'Utility');
24-
App::uses('String', 'Utility');
24+
App::uses('CakeText', 'Utility');
2525
App::uses('Hash', 'Utility');
2626
App::uses('BehaviorCollection', 'Model');
2727
App::uses('ModelBehavior', 'Model');
@@ -1748,9 +1748,9 @@ public function save($data = null, $validate = true, $fieldList = array()) {
17481748
if (empty($this->data[$this->alias][$this->primaryKey]) && $isUUID) {
17491749
if (array_key_exists($this->primaryKey, $this->data[$this->alias])) {
17501750
$j = array_search($this->primaryKey, $fields);
1751-
$values[$j] = String::uuid();
1751+
$values[$j] = CakeText::uuid();
17521752
} else {
1753-
list($fields[], $values[]) = array($this->primaryKey, String::uuid());
1753+
list($fields[], $values[]) = array($this->primaryKey, CakeText::uuid());
17541754
}
17551755
}
17561756

@@ -1842,7 +1842,7 @@ protected function _saveMulti($joined, $id, $db) {
18421842
$newJoins[] = $row;
18431843
$values = array($id, $row);
18441844
if ($isUUID && $primaryAdded) {
1845-
$values[] = String::uuid();
1845+
$values[] = CakeText::uuid();
18461846
}
18471847
$newValues[$row] = $values;
18481848
unset($values);
@@ -2909,7 +2909,7 @@ protected function _findList($state, $query, $results = array()) {
29092909
$list = array("{n}.{$this->alias}.{$this->primaryKey}", "{n}.{$this->alias}.{$this->displayField}", null);
29102910
} else {
29112911
if (!is_array($query['fields'])) {
2912-
$query['fields'] = String::tokenize($query['fields']);
2912+
$query['fields'] = CakeText::tokenize($query['fields']);
29132913
}
29142914

29152915
if (count($query['fields']) === 1) {

core/lib/Cake/Network/Email/CakeEmail.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
App::uses('Validation', 'Utility');
2121
App::uses('Multibyte', 'I18n');
2222
App::uses('AbstractTransport', 'Network/Email');
23-
App::uses('String', 'Utility');
23+
App::uses('CakeText', 'Utility');
2424
App::uses('View', 'View');
2525
App::import('I18n', 'Multibyte');
2626

@@ -711,7 +711,7 @@ public function getHeaders($include = array()) {
711711
}
712712
if ($this->_messageId !== false) {
713713
if ($this->_messageId === true) {
714-
$headers['Message-ID'] = '<' . str_replace('-', '', String::UUID()) . '@' . $this->_domain . '>';
714+
$headers['Message-ID'] = '<' . str_replace('-', '', CakeText::UUID()) . '@' . $this->_domain . '>';
715715
} else {
716716
$headers['Message-ID'] = $this->_messageId;
717717
}

core/lib/Cake/Utility/String.php core/lib/Cake/Utility/CakeText.php

+10-10
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
*
2424
* @package Cake.Utility
2525
*/
26-
class String {
26+
class CakeText {
2727

2828
/**
2929
* Generate a random UUID
@@ -181,7 +181,7 @@ public static function tokenize($data, $separator = ',', $leftBound = '(', $righ
181181
/**
182182
* Replaces variable placeholders inside a $str with any given $data. Each key in the $data array
183183
* corresponds to a variable placeholder name in $str.
184-
* Example: `String::insert(':name is :age years old.', array('name' => 'Bob', '65'));`
184+
* Example: `CakeText::insert(':name is :age years old.', array('name' => 'Bob', '65'));`
185185
* Returns: Bob is 65 years old.
186186
*
187187
* Available $options are:
@@ -191,7 +191,7 @@ public static function tokenize($data, $separator = ',', $leftBound = '(', $righ
191191
* - escape: The character or string used to escape the before character / string (Defaults to `\`)
192192
* - format: A regex to use for matching variable placeholders. Default is: `/(?<!\\)\:%s/`
193193
* (Overwrites before, after, breaks escape / clean)
194-
* - clean: A boolean or array with instructions for String::cleanInsert
194+
* - clean: A boolean or array with instructions for CakeText::cleanInsert
195195
*
196196
* @param string $str A string containing variable placeholders
197197
* @param string $data A key => val array where each key stands for a placeholder variable name
@@ -207,7 +207,7 @@ public static function insert($str, $data, $options = array()) {
207207
$format = $options['format'];
208208
$data = (array)$data;
209209
if (empty($data)) {
210-
return ($options['clean']) ? String::cleanInsert($str, $options) : $str;
210+
return ($options['clean']) ? CakeText::cleanInsert($str, $options) : $str;
211211
}
212212

213213
if (!isset($format)) {
@@ -226,7 +226,7 @@ public static function insert($str, $data, $options = array()) {
226226
$offset = $pos + strlen($val);
227227
$str = substr_replace($str, $val, $pos, 1);
228228
}
229-
return ($options['clean']) ? String::cleanInsert($str, $options) : $str;
229+
return ($options['clean']) ? CakeText::cleanInsert($str, $options) : $str;
230230
} else {
231231
asort($data);
232232

@@ -251,19 +251,19 @@ public static function insert($str, $data, $options = array()) {
251251
if (!isset($options['format']) && isset($options['before'])) {
252252
$str = str_replace($options['escape'] . $options['before'], $options['before'], $str);
253253
}
254-
return ($options['clean']) ? String::cleanInsert($str, $options) : $str;
254+
return ($options['clean']) ? CakeText::cleanInsert($str, $options) : $str;
255255
}
256256

257257
/**
258-
* Cleans up a String::insert() formatted string with given $options depending on the 'clean' key in
258+
* Cleans up a CakeText::insert() formatted string with given $options depending on the 'clean' key in
259259
* $options. The default method used is text but html is also available. The goal of this function
260260
* is to replace all whitespace and unneeded markup around placeholders that did not get replaced
261-
* by String::insert().
261+
* by CakeText::insert().
262262
*
263263
* @param string $str
264264
* @param string $options
265265
* @return string
266-
* @see String::insert()
266+
* @see CakeText::insert()
267267
*/
268268
public static function cleanInsert($str, $options) {
269269
$clean = $options['clean'];
@@ -292,7 +292,7 @@ public static function cleanInsert($str, $options) {
292292
$str = preg_replace($kleenex, $clean['replacement'], $str);
293293
if ($clean['andText']) {
294294
$options['clean'] = array('method' => 'text');
295-
$str = String::cleanInsert($str, $options);
295+
$str = CakeText::cleanInsert($str, $options);
296296
}
297297
break;
298298
case 'text':

core/lib/Cake/Utility/Debugger.php

+6-6
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
*/
2121

2222
App::uses('CakeLog', 'Log');
23-
App::uses('String', 'Utility');
23+
App::uses('CakeText', 'Utility');
2424

2525
/**
2626
* Provide custom logging and error handling.
@@ -340,7 +340,7 @@ public static function trace($options = array()) {
340340
$trace['path'] = self::trimPath($trace['file']);
341341
$trace['reference'] = $reference;
342342
unset($trace['object'], $trace['args']);
343-
$back[] = String::insert($tpl, $trace, array('before' => '{:', 'after' => '}'));
343+
$back[] = CakeText::insert($tpl, $trace, array('before' => '{:', 'after' => '}'));
344344
}
345345
}
346346

@@ -606,7 +606,7 @@ public static function outputAs($format = null) {
606606
*
607607
* `Debugger::addFormat('custom', $data);`
608608
*
609-
* Where $data is an array of strings that use String::insert() variable
609+
* Where $data is an array of strings that use CakeText::insert() variable
610610
* replacement. The template vars should be in a `{:id}` style.
611611
* An error formatter can have the following keys:
612612
*
@@ -738,7 +738,7 @@ public function outputError($data) {
738738

739739
if (isset($tpl['links'])) {
740740
foreach ($tpl['links'] as $key => $val) {
741-
$links[$key] = String::insert($val, $data, $insertOpts);
741+
$links[$key] = CakeText::insert($val, $data, $insertOpts);
742742
}
743743
}
744744

@@ -754,14 +754,14 @@ public function outputError($data) {
754754
if (is_array($value)) {
755755
$value = join("\n", $value);
756756
}
757-
$info .= String::insert($tpl[$key], array($key => $value) + $data, $insertOpts);
757+
$info .= CakeText::insert($tpl[$key], array($key => $value) + $data, $insertOpts);
758758
}
759759
$links = join(' ', $links);
760760

761761
if (isset($tpl['callback']) && is_callable($tpl['callback'])) {
762762
return call_user_func($tpl['callback'], $data, compact('links', 'info'));
763763
}
764-
echo String::insert($tpl['error'], compact('links', 'info') + $data, $insertOpts);
764+
echo CakeText::insert($tpl['error'], compact('links', 'info') + $data, $insertOpts);
765765
}
766766

767767
/**

core/lib/Cake/Utility/Hash.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
1414
*/
1515

16-
App::uses('String', 'Utility');
16+
App::uses('CakeText', 'Utility');
1717

1818
/**
1919
* Library of array functions for manipulating and extracting data
@@ -99,7 +99,7 @@ public static function extract(array $data, $path) {
9999
if (strpos('[', $path) === false) {
100100
$tokens = explode('.', $path);
101101
} else {
102-
$tokens = String::tokenize($path, '.', '[', ']');
102+
$tokens = CakeText::tokenize($path, '.', '[', ']');
103103
}
104104

105105
$_key = '__set_item__';

core/lib/Cake/Utility/Security.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
1818
*/
1919

20-
App::uses('String', 'Utility');
20+
App::uses('CakeText', 'Utility');
2121

2222
/**
2323
* Security Library contains utility methods related to security
@@ -59,7 +59,7 @@ public static function inactiveMins() {
5959
* @return string Hash
6060
*/
6161
public static function generateAuthKey() {
62-
return Security::hash(String::uuid());
62+
return Security::hash(CakeText::uuid());
6363
}
6464

6565
/**

0 commit comments

Comments
 (0)